QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834306 | #8519. Radars | suo | WA | 1ms | 3688kb | C++20 | 1.4kb | 2024-12-27 15:08:27 | 2024-12-27 15:08:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> a;
int getmin(int l, int r, int u, int d) {
int res = 1 << 30;
for (int i = l; i < r; i++) {
for (int j = u; j < d; j++) {
res = min(res, a[j][i]);
}
}
return res;
}
void solve() {
int n;
cin >> n;
a.resize(n);
for (int i = 0; i < n; i++) {
a[i].resize(n);
for (int j = 0; j < n; j++) {
cin >> a[i][j];
}
}
if (n == 1) {
cout << a[0][0] << endl;
return;
}
int q1 = getmin(0, n / 2, 0, n / 2);
int q2 = getmin(n / 2 + 1, n, 0, n / 2);
int q3 = getmin(0, n / 2, n / 2 + 1, n);
int q4 = getmin(n / 2 + 1, n, n / 2 + 1, n);
int m1 = getmin(n / 2, n / 2 + 1, 0, n / 2);
int m2 = getmin(0, n / 2, n / 2, n / 2 + 1);
int m3 = getmin(n / 2, n / 2 + 1, n / 2 + 1, n);
int m4 = getmin(n / 2 + 1, n, n / 2, n / 2 + 1);
int q = a[n / 2][n / 2];
int upmin = min(min(q1, m2) + min(q2, m4), m1);
int dwmin = min(min(q3, m2) + min(q4, m4), m3);
int lmin = min(min(q1, m1) + min(q3, m3), m2);
int rmin = min(min(q2, m2) + min(q4, m3), m4);
int ans = min(a[n / 2][n / 2], min(upmin + dwmin, lmin + rmin));
cout << ans << endl;
}
int main() {
int t;
cin >> t;
while (t > 0) {
t--;
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
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: 3624kb
input:
1 1 444739567
output:
444739567
result:
ok 1 number(s): "444739567"
Test #3:
score: -100
Wrong Answer
time: 1ms
memory: 3688kb
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 44067838 226890388 50684672 954430705 139405747 530064327 199272913 211829225 333898451 217089022 35580250 251879512 230866303 60323753 215243437 114032585 256967033 361741480 49710371 75128942 269414925 755829169 133537759 108744675 691515792 193230413 469380143 156043031 227141...
result:
wrong answer 3rd numbers differ - expected: '47298040', found: '44067838'