#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
int n, mx;
vector<int> dx = {-1, 0, 1, 0}, dy = {0, 1, 0, -1};
vector<vector<int>> a, v;
void f(int x) {
if (x == n * n) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!v[i][j]) continue;
vector<vector<bool>> vis(n, vector<bool>(n));
vis[i][j] = true;
for (int z = 0; z < 2; z++) {
vector<vector<bool>> vis2(n, vector<bool>(n));
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++) {
if (!vis[k][l]) continue;
for (int m = l - 1; m >= 0 && v[k][m]; m--)
vis2[k][m] = true;
for (int m = l + 1; m < n && v[k][m]; m++)
vis2[k][m] = true;
for (int m = k - 1; m >= 0 && v[m][l]; m--)
vis2[m][l] = true;
for (int m = k + 1; m < n && v[m][l]; m++)
vis2[m][l] = true;
}
}
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++)
if (vis2[k][l]) vis[k][l] = true;
}
}
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++)
if (v[k][l] && !vis[k][l]) return;
}
}
}
int cnt = 0;
for (auto i : v)
cnt += count(i.begin(), i.end(), 1);
mx = max(mx, cnt);
return;
}
for (int i = 0; i < 2; i++) {
if (i && a[x / n][x % n]) return;
v[x / n][x % n] = i;
f(x + 1);
}
}
int biggest_stadium(int N, vector<vector<int>> F) {
n = N; a = F;
int cnt = 0;
for (auto i : a)
cnt += count(i.begin(), i.end(), 1);
bool tr = true;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[i][j]) continue;
vector<vector<bool>> vis(n, vector<bool>(n));
vis[i][j] = true;
for (int z = 0; z < 2; z++) {
vector<vector<bool>> vis2(n, vector<bool>(n));
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++) {
if (!vis[k][l]) continue;
for (int m = l - 1; m >= 0 && !a[k][m]; m--)
vis2[k][m] = true;
for (int m = l + 1; m < n && !a[k][m]; m++)
vis2[k][m] = true;
for (int m = k - 1; m >= 0 && !a[m][l]; m--)
vis2[m][l] = true;
for (int m = k + 1; m < n && !a[m][l]; m++)
vis2[m][l] = true;
}
}
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++)
if (vis2[k][l]) vis[k][l] = true;
}
}
for (int k = 0; k < n; k++) {
for (int l = 0; l < n; l++)
if (!a[k][l] && !vis[k][l]) tr = false;
}
}
}
vector<vector<bool>> vis(n, vector<bool>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (!a[i][j]) {
queue<pair<int, int>> q;
q.push({i, j});
while (!q.empty()) {
auto [x, y] = q.front(); q.pop();
vis[x][y] = true;
for (int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if (0 <= min(nx, ny) && max(nx, ny) < n && !a[nx][ny] && !vis[nx][ny]) {
vis[nx][ny] = true;
q.push({nx, ny});
}
}
}
break;
}
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
if (!a[i][j] && !vis[i][j]) return 0;
}
vector<vector<int>> p(n, vector<int>(n));
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++)
p[i][j] = (i ? p[i - 1][j] : 0) + (j ? p[i][j - 1] : 0) - (i && j ? p[i - 1][j - 1] : 0) + !a[i][j];
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
int x = (i ? p[i - 1][j] : 0), y = (j ? p[i][j - 1] : 0);
if (a[i][j] && p[i][j] && p[n - 1][j] != x && p[i][n - 1] != y && p[n - 1][n - 1] + (i && j ? p[i - 1][j - 1] : 0) != x + y) return 0;
}
}
assert(tr);
return n * n - cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
432 KB |
partial |
7 |
Partially correct |
1269 ms |
568 KB |
partial |
8 |
Execution timed out |
4531 ms |
3928 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
1 ms |
348 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
1 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Partially correct |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Runtime error |
0 ms |
604 KB |
Execution killed with signal 6 |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
0 ms |
432 KB |
partial |
8 |
Partially correct |
1269 ms |
568 KB |
partial |
9 |
Execution timed out |
4531 ms |
3928 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |