QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#443775 | #8519. Radars | ucup-team3564# | WA | 0ms | 3840kb | C++20 | 2.4kb | 2024-06-15 16:29:54 | 2024-06-15 16:29:54 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "\033[32m[" << __LINE__ << "]\033[0m "
#define SZ(x) ((int) x.size() - 1)
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> T& chkmax(T &x, T y) {return x = max(x, y);}
template <typename T> T& chkmin(T &x, T y) {return x = min(x, y);}
template <typename T> T& read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = - f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x *= f;
}
const int N = 510, inf = 1e9;
int n, a[N][N];
void zhk() {
read(n);
int ans = inf;
vector <int> t[3][3];
F(i, 1, n)
F(j, 1, n) {
read(a[i][j]);
int ti, tj;
if (i < n / 2 + 1) ti = 0;
else if (i == n / 2 + 1) ti = 1;
else ti = 2;
if (j < n / 2 + 1) tj = 0;
else if (j == n / 2 + 1) tj = 1;
else tj = 2;
t[ti][tj].push_back(a[i][j]);
}
if (n == 1) {
cout << t[1][1][0] << '\n';
return;
}
F(i, 0, 2)
F(j, 0, 2)
sort(all(t[i][j]));
chkmin(ans, t[1][1][0]);
chkmin(ans, t[1][0][0] + t[1][2][0]);
chkmin(ans, t[0][1][0] + t[2][1][0]);
// debug << t[1][2][0] << " " << min(t[0][0][0], t[1][0][0]) << " " << min(t[2][0][0], t[1][0][0]) << endl;
chkmin(ans, t[1][0][0] + min(t[0][2][0], t[0][1][0]) + min(t[2][2][0], t[2][1][0]));
chkmin(ans, t[1][2][0] + min(t[0][0][0], t[0][1][0]) + min(t[2][0][0], t[2][1][0]));
chkmin(ans, t[0][1][0] + min(t[2][0][0], t[1][0][0]) + min(t[2][2][0], t[1][2][0]));
chkmin(ans, t[2][1][0] + min(t[0][0][0], t[1][0][0]) + min(t[0][2][0], t[1][2][0]));
chkmin(ans, t[0][0][0] + t[2][0][0] + t[0][2][0] + t[2][2][0]);
// {
// vector <int> t;
// F(i, 1, n) t.push_back(a[n / 2 + 1][i]);
// sort(all(t));
// chkmin(ans, t[0] + t[1]);
// }
// {
// vector <int> t;
// F(i, 1, n) t.push_back(a[i][n / 2 + 1]);
// sort(all(t));
// chkmin(ans, t[0] + t[1]);
// }
// {
// vector <int> t;
// F(i, 1, n / 2 + 1) t.push_back(a[i][n / 2 + 1]);
// sort(all(t));
// chkmin(ans, t[0] + t[1]);
// }
cout << ans << '\n';
}
signed main() {
int _ = 1;
cin >> _;
while (_--) zhk();
return 0;
}
/* why?
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3840kb
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: 3532kb
input:
1 1 444739567
output:
444739567
result:
ok 1 number(s): "444739567"
Test #3:
score: -100
Wrong Answer
time: 0ms
memory: 3548kb
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 -1697659383 47298040 226890388 50684672 954430705 139405747 530064327 199272913 211829225 -2041277180 217089022 35580250 251879512 230866303 60323753 215243437 114032585 351186098 361741480 49710371 75128942 269414925 755829169 133537759 108744675 691515792 193230413 469380143 156043031 22...
result:
wrong answer 2nd numbers differ - expected: '661643843', found: '-1697659383'