#include <bits/stdc++.h>
using namespace std;
int biggest_stadium(int n, vector<vector<int>> f) {
vector<vector<int>> pr_sum(n + 1, vector<int>(n + 1));
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
f[i][j] ^= 1;
pr_sum[i + 1][j + 1] = pr_sum[i + 1][j] + pr_sum[i][j + 1] - pr_sum[i][j] + f[i][j];
}
}
if (pr_sum[n][n] == n * n - 1) {
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (!f[i][j]) {
if (n * n - min(i + 1, n - i) * min(j + 1, n - j) == n * n - 1) {
return n * n - 1;
}
return n * n - 2;
return n * n - min(i + 1, n - i) * min(j + 1, n - j);
}
}
}
}
vector<vector<int>> ll(n, vector<int>(n, -1)), rr(n, vector<int>(n, n)), dd(n, vector<int>(n, n));
for (int i = n - 1; i >= 0; --i) {
for (int j = 0; j < n; ++j) {
if (!f[i][j]) {
ll[i][j] = j;
dd[i][j] = i;
} else {
if (j > 0) {
ll[i][j] = ll[i][j - 1];
}
if (i + 1 < n) {
dd[i][j] = dd[i + 1][j];
}
}
}
for (int j = n - 1; j >= 0; --j) {
if (!f[i][j]) {
rr[i][j] = j;
} else if (j + 1 < n) {
rr[i][j] = rr[i][j + 1];
}
}
}
bool check = true;
auto get = [&](int i1, int j1, int i2, int j2) {
return pr_sum[i2][j2] - pr_sum[i1][j2] - pr_sum[i2][j1] + pr_sum[i1][j1];
};
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (!f[i][j]) {
continue;
}
int l = ll[i][j], r = rr[i][j], d = dd[i][j];
if (get(i, 0, i + 1, l + 1) || get(i, d, i + 1, n) || get(i, r, i + 1, n)) {
check = false;
}
if (l > -1 && d < n) {
if (get(d + 1, 0, n, l)) {
check = false;
}
}
if (r < n && d < n) {
if (get(d + 1, r + 1, n, n)) {
check = false;
}
}
}
}
if (check) {
return pr_sum[n][n];
} else {
return pr_sum[n][n] - 1;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
0 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
340 KB |
ok |
6 |
Partially correct |
0 ms |
212 KB |
partial |
7 |
Partially correct |
1 ms |
340 KB |
partial |
8 |
Partially correct |
24 ms |
3216 KB |
partial |
9 |
Partially correct |
300 ms |
47496 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
ok |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
256 KB |
ok |
7 |
Correct |
1 ms |
212 KB |
ok |
8 |
Correct |
0 ms |
212 KB |
ok |
9 |
Correct |
0 ms |
212 KB |
ok |
10 |
Correct |
1 ms |
212 KB |
ok |
11 |
Correct |
1 ms |
212 KB |
ok |
12 |
Correct |
1 ms |
212 KB |
ok |
13 |
Incorrect |
0 ms |
212 KB |
wrong |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
212 KB |
ok |
7 |
Correct |
1 ms |
256 KB |
ok |
8 |
Correct |
1 ms |
212 KB |
ok |
9 |
Correct |
0 ms |
212 KB |
ok |
10 |
Correct |
0 ms |
212 KB |
ok |
11 |
Correct |
1 ms |
212 KB |
ok |
12 |
Correct |
1 ms |
212 KB |
ok |
13 |
Correct |
1 ms |
212 KB |
ok |
14 |
Incorrect |
0 ms |
212 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
0 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
212 KB |
ok |
7 |
Correct |
1 ms |
212 KB |
ok |
8 |
Correct |
1 ms |
212 KB |
ok |
9 |
Correct |
1 ms |
256 KB |
ok |
10 |
Correct |
1 ms |
212 KB |
ok |
11 |
Correct |
0 ms |
212 KB |
ok |
12 |
Correct |
0 ms |
212 KB |
ok |
13 |
Correct |
1 ms |
212 KB |
ok |
14 |
Correct |
1 ms |
212 KB |
ok |
15 |
Correct |
1 ms |
212 KB |
ok |
16 |
Incorrect |
0 ms |
212 KB |
wrong |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
0 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
212 KB |
ok |
7 |
Correct |
1 ms |
212 KB |
ok |
8 |
Correct |
1 ms |
212 KB |
ok |
9 |
Correct |
1 ms |
256 KB |
ok |
10 |
Correct |
1 ms |
212 KB |
ok |
11 |
Correct |
0 ms |
212 KB |
ok |
12 |
Correct |
0 ms |
212 KB |
ok |
13 |
Correct |
1 ms |
212 KB |
ok |
14 |
Correct |
1 ms |
212 KB |
ok |
15 |
Correct |
1 ms |
212 KB |
ok |
16 |
Incorrect |
0 ms |
212 KB |
wrong |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
212 KB |
partial |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
0 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
340 KB |
ok |
7 |
Partially correct |
0 ms |
212 KB |
partial |
8 |
Partially correct |
1 ms |
340 KB |
partial |
9 |
Partially correct |
24 ms |
3216 KB |
partial |
10 |
Partially correct |
300 ms |
47496 KB |
partial |
11 |
Correct |
1 ms |
212 KB |
ok |
12 |
Correct |
1 ms |
212 KB |
ok |
13 |
Correct |
1 ms |
212 KB |
ok |
14 |
Correct |
1 ms |
256 KB |
ok |
15 |
Correct |
1 ms |
212 KB |
ok |
16 |
Correct |
0 ms |
212 KB |
ok |
17 |
Correct |
0 ms |
212 KB |
ok |
18 |
Correct |
1 ms |
212 KB |
ok |
19 |
Correct |
1 ms |
212 KB |
ok |
20 |
Correct |
1 ms |
212 KB |
ok |
21 |
Incorrect |
0 ms |
212 KB |
wrong |
22 |
Halted |
0 ms |
0 KB |
- |