QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#456822 | #8519. Radars | supepapupu | WA | 0ms | 3880kb | C++20 | 1.6kb | 2024-06-28 14:44:36 | 2024-06-28 14:44:37 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cerr << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
void solve() {
int n; cin >> n;
vector<vector<ll>> a(n, vector<ll>(n));
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
cin >> a[i][j];
ll ans = a[n / 2][n / 2];
if (n == 1) return cout << ans << el, void();
vector<ll> x, y;
for (int i = 0; i < n; ++i) x.emplace_back(a[n / 2][i]), y.emplace_back(a[i][n / 2]);
sort(x.begin(), x.end()), sort(y.begin(), y.end());
ans = min({ans, x[0] + x[1], y[0] + y[1]});
vector<vector<ll>> b(2, vector<ll>(2, INF));
for (int i = 0; i < n / 2; ++i)
for (int j = 0; j < n / 2; ++j)
for (int x = 0; x < 2; ++x)
for (int y = 0; y < 2; ++y)
b[x][y] = min(b[x][y], a[i + n / 2 * x][j + n / 2 * y]);
ans = min(ans, b[0][0] + b[0][1] + b[1][0] + b[1][1]);
for (int i = 0; i < n; ++i) {
if (i < n / 2) {
ans = min(ans, a[i][n / 2] + b[1][0] + b[1][1]);
ans = min(ans, a[n / 2][i] + b[0][1] + b[1][1]);
} else {
ans = min(ans, a[i][n / 2] + b[0][0] + b[0][1]);
ans = min(ans, a[n / 2][i] + b[0][0] + b[1][0]);
}
}
cout << ans << el;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int tcase = 1;
cin >> tcase;
while (tcase--) solve();
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3580kb
input:
2 3 1 1 1 1 1 1 1 1 1 5 8 5 2 8 3 5 6 9 7 3 7 8 9 1 4 8 9 4 5 5 2 8 6 9 3
output:
1 5
result:
ok 2 number(s): "1 5"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3580kb
input:
1 1 444739567
output:
444739567
result:
ok 1 number(s): "444739567"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3880kb
input:
32 5 177252602 814271963 432801178 401470194 888319541 320323627 34071000 116035631 87392694 926990496 423510770 515133425 777623990 140441392 853473387 976288681 925949889 930584554 939702106 761328886 840677679 912446055 378955738 997133668 334407172 3 633852912 89450314 828384045 327867173 732812...
output:
494991369 661643843 47298040 190261304 50938764 954430705 180751388 551797206 199272913 175039535 333898451 399706780 35580250 251879512 287312486 60323753 215243437 114032585 147200354 361741480 49710371 75128942 269414925 755829169 133537759 199228271 691515792 193230413 469380143 193907544 227141...
result:
wrong answer 4th numbers differ - expected: '226890388', found: '190261304'