#include <bits/stdc++.h>
using namespace std;
struct Pos {
int x, y;
Pos(int x, int y) : x(x), y(y) {}
};
bool FIELD[2001][2001] = {0};
// bool empty(int a, int b, int x, int y) {
// assert(a == x || b == y); // only 1d queries
// if (a == x)
// for (int i = min(b, y); i <= max(b, y); i++)
// if (FIELD[a][i]) return false;
// if (b == y)
// for (int i = min(a, x); i <= max(a, x); i++)
// if (FIELD[i][b]) return false;
// return true;
// }
int biggest_stadium(int N, vector<vector<int>> F) {
vector<Pos> trees;
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
if (F[i][j] == 1) trees.push_back({i, j});
FIELD[i][j] = F[i][j];
}
for (auto tree : trees) {
cerr << tree.x << " " << tree.y << endl;
}
if (trees.size() == 0) return N * N;
if (trees.size() == 1) {
int x = trees[0].x, y = trees[0].y;
int n = N - 1;
int a = (abs(x - 0) + 1) * (abs(y - 0) + 1);
int b = (abs(x - 0) + 1) * (abs(y - n) + 1);
int c = (abs(x - n) + 1) * (abs(y - 0) + 1);
int d = (abs(x - n) + 1) * (abs(y - n) + 1);
return N * N - min({a, b, c, d});
}
const int MAXN = 500;
set<set<pair<int, int>>> cover;
set<pair<int, int>> last;
for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) {
if (FIELD[i][j] == 1) continue;
const int DIRS[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
// x, y and direction and the kick
// 0 = first kick, 1 = second kick
queue<tuple<int, int, int, bool>> q;
bool used[MAXN][MAXN][4][2] = {0};
bool visited[MAXN][MAXN] = {0};
set<pair<int, int>> vis;
visited[i][j] = true;
vis.insert({i, j});
for (int d = 0; d < 4; d++) {
used[i][j][d][0] = true;
q.push({i, j, d, 0});
}
while (!q.empty()) {
auto [x, y, d, k] = q.front(); q.pop();
x += DIRS[d][0];
y += DIRS[d][1];
if (x < 0 || x >= N || y < 0 || y >= N) continue;
if (FIELD[x][y]) continue;
if (used[x][y][d][k]) continue;
visited[x][y] = true;
vis.insert({x, y});
used[x][y][d][k] = true;
q.push({x, y, d, k});
if (k == true) continue;
for (int d = 0; d < 4; d++) {
used[x][y][d][1] = true;
q.push({x, y, d, 1});
}
}
cover.insert(vis);
last = vis;
cerr << "ceverage from " << i << " " << j << endl;
for (int a = 0; a < N; a++) {
for (int b = 0; b < N; b++) {
if (a == i && b == j) cerr << "@";
else if (FIELD[a][b]) cerr << "#";
else if (visited[a][b]) cerr << "+";
else cerr << " ";
cerr << " ";
}
cerr << '\n';
}
}
if (cover.size() == 1 && last.size() == N * N - trees.size())
return N * N - trees.size();
return 0;
// for (int a = 0; a < N; a++) for (int b = 0; b < N; b++) {
// for (int x = 0; x < N; x++) for (int y = 0; y < N; y++) {
// // going throgh (a, y)
// if (a == x && b == y) continue;
// if (FIELD[a][b] || FIELD[x][y]) continue;
// if ((empty(a, b, a, y) && empty(x, y, a, y))
// || empty(a, b, x, b) && empty(x, y, x, b)) {
// continue;
// } else {return 0;}
// }
// }
// return N * N - trees.size();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2652 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2488 KB |
ok |
2 |
Correct |
1 ms |
2652 KB |
ok |
3 |
Correct |
1 ms |
2652 KB |
ok |
4 |
Correct |
1 ms |
2652 KB |
ok |
5 |
Correct |
1 ms |
2392 KB |
ok |
6 |
Correct |
1 ms |
2652 KB |
ok |
7 |
Correct |
2 ms |
2908 KB |
ok |
8 |
Correct |
13 ms |
5976 KB |
ok |
9 |
Correct |
201 ms |
45720 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2488 KB |
ok |
2 |
Correct |
1 ms |
2652 KB |
ok |
3 |
Partially correct |
2 ms |
2648 KB |
partial |
4 |
Partially correct |
2 ms |
2652 KB |
partial |
5 |
Partially correct |
2 ms |
2652 KB |
partial |
6 |
Partially correct |
2 ms |
2652 KB |
partial |
7 |
Partially correct |
2 ms |
2652 KB |
partial |
8 |
Correct |
2 ms |
2652 KB |
ok |
9 |
Correct |
1 ms |
2648 KB |
ok |
10 |
Partially correct |
2 ms |
2648 KB |
partial |
11 |
Partially correct |
2 ms |
2652 KB |
partial |
12 |
Partially correct |
2 ms |
2648 KB |
partial |
13 |
Correct |
2 ms |
2652 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2652 KB |
partial |
2 |
Correct |
1 ms |
2488 KB |
ok |
3 |
Correct |
1 ms |
2652 KB |
ok |
4 |
Partially correct |
2 ms |
2648 KB |
partial |
5 |
Partially correct |
2 ms |
2652 KB |
partial |
6 |
Partially correct |
2 ms |
2652 KB |
partial |
7 |
Partially correct |
2 ms |
2652 KB |
partial |
8 |
Partially correct |
2 ms |
2652 KB |
partial |
9 |
Correct |
2 ms |
2652 KB |
ok |
10 |
Correct |
1 ms |
2648 KB |
ok |
11 |
Partially correct |
2 ms |
2648 KB |
partial |
12 |
Partially correct |
2 ms |
2652 KB |
partial |
13 |
Partially correct |
2 ms |
2648 KB |
partial |
14 |
Correct |
2 ms |
2652 KB |
ok |
15 |
Partially correct |
14 ms |
2652 KB |
partial |
16 |
Partially correct |
8 ms |
2652 KB |
partial |
17 |
Partially correct |
7 ms |
2652 KB |
partial |
18 |
Partially correct |
6 ms |
2488 KB |
partial |
19 |
Partially correct |
5 ms |
2652 KB |
partial |
20 |
Correct |
3 ms |
2652 KB |
ok |
21 |
Correct |
3 ms |
2652 KB |
ok |
22 |
Partially correct |
4 ms |
2652 KB |
partial |
23 |
Partially correct |
4 ms |
2652 KB |
partial |
24 |
Partially correct |
3 ms |
2652 KB |
partial |
25 |
Partially correct |
5 ms |
2652 KB |
partial |
26 |
Partially correct |
8 ms |
2492 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2652 KB |
partial |
2 |
Correct |
1 ms |
2488 KB |
ok |
3 |
Correct |
1 ms |
2652 KB |
ok |
4 |
Correct |
1 ms |
2652 KB |
ok |
5 |
Correct |
1 ms |
2652 KB |
ok |
6 |
Partially correct |
2 ms |
2648 KB |
partial |
7 |
Partially correct |
2 ms |
2652 KB |
partial |
8 |
Partially correct |
2 ms |
2652 KB |
partial |
9 |
Partially correct |
2 ms |
2652 KB |
partial |
10 |
Partially correct |
2 ms |
2652 KB |
partial |
11 |
Correct |
2 ms |
2652 KB |
ok |
12 |
Correct |
1 ms |
2648 KB |
ok |
13 |
Partially correct |
2 ms |
2648 KB |
partial |
14 |
Partially correct |
2 ms |
2652 KB |
partial |
15 |
Partially correct |
2 ms |
2648 KB |
partial |
16 |
Correct |
2 ms |
2652 KB |
ok |
17 |
Partially correct |
14 ms |
2652 KB |
partial |
18 |
Partially correct |
8 ms |
2652 KB |
partial |
19 |
Partially correct |
7 ms |
2652 KB |
partial |
20 |
Partially correct |
6 ms |
2488 KB |
partial |
21 |
Partially correct |
5 ms |
2652 KB |
partial |
22 |
Correct |
3 ms |
2652 KB |
ok |
23 |
Correct |
3 ms |
2652 KB |
ok |
24 |
Partially correct |
4 ms |
2652 KB |
partial |
25 |
Partially correct |
4 ms |
2652 KB |
partial |
26 |
Partially correct |
3 ms |
2652 KB |
partial |
27 |
Partially correct |
5 ms |
2652 KB |
partial |
28 |
Partially correct |
8 ms |
2492 KB |
partial |
29 |
Partially correct |
6 ms |
2652 KB |
partial |
30 |
Partially correct |
1481 ms |
10720 KB |
partial |
31 |
Partially correct |
1318 ms |
6192 KB |
partial |
32 |
Partially correct |
795 ms |
3440 KB |
partial |
33 |
Partially correct |
164 ms |
2904 KB |
partial |
34 |
Correct |
235 ms |
2752 KB |
ok |
35 |
Correct |
471 ms |
3156 KB |
ok |
36 |
Partially correct |
221 ms |
2760 KB |
partial |
37 |
Partially correct |
257 ms |
2896 KB |
partial |
38 |
Partially correct |
309 ms |
2896 KB |
partial |
39 |
Partially correct |
407 ms |
3156 KB |
partial |
40 |
Partially correct |
1137 ms |
3668 KB |
partial |
41 |
Partially correct |
1697 ms |
16980 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2652 KB |
partial |
2 |
Correct |
1 ms |
2488 KB |
ok |
3 |
Correct |
1 ms |
2652 KB |
ok |
4 |
Correct |
1 ms |
2652 KB |
ok |
5 |
Correct |
1 ms |
2652 KB |
ok |
6 |
Partially correct |
2 ms |
2648 KB |
partial |
7 |
Partially correct |
2 ms |
2652 KB |
partial |
8 |
Partially correct |
2 ms |
2652 KB |
partial |
9 |
Partially correct |
2 ms |
2652 KB |
partial |
10 |
Partially correct |
2 ms |
2652 KB |
partial |
11 |
Correct |
2 ms |
2652 KB |
ok |
12 |
Correct |
1 ms |
2648 KB |
ok |
13 |
Partially correct |
2 ms |
2648 KB |
partial |
14 |
Partially correct |
2 ms |
2652 KB |
partial |
15 |
Partially correct |
2 ms |
2648 KB |
partial |
16 |
Correct |
2 ms |
2652 KB |
ok |
17 |
Partially correct |
14 ms |
2652 KB |
partial |
18 |
Partially correct |
8 ms |
2652 KB |
partial |
19 |
Partially correct |
7 ms |
2652 KB |
partial |
20 |
Partially correct |
6 ms |
2488 KB |
partial |
21 |
Partially correct |
5 ms |
2652 KB |
partial |
22 |
Correct |
3 ms |
2652 KB |
ok |
23 |
Correct |
3 ms |
2652 KB |
ok |
24 |
Partially correct |
4 ms |
2652 KB |
partial |
25 |
Partially correct |
4 ms |
2652 KB |
partial |
26 |
Partially correct |
3 ms |
2652 KB |
partial |
27 |
Partially correct |
5 ms |
2652 KB |
partial |
28 |
Partially correct |
8 ms |
2492 KB |
partial |
29 |
Partially correct |
6 ms |
2652 KB |
partial |
30 |
Partially correct |
1481 ms |
10720 KB |
partial |
31 |
Partially correct |
1318 ms |
6192 KB |
partial |
32 |
Partially correct |
795 ms |
3440 KB |
partial |
33 |
Partially correct |
164 ms |
2904 KB |
partial |
34 |
Correct |
235 ms |
2752 KB |
ok |
35 |
Correct |
471 ms |
3156 KB |
ok |
36 |
Partially correct |
221 ms |
2760 KB |
partial |
37 |
Partially correct |
257 ms |
2896 KB |
partial |
38 |
Partially correct |
309 ms |
2896 KB |
partial |
39 |
Partially correct |
407 ms |
3156 KB |
partial |
40 |
Partially correct |
1137 ms |
3668 KB |
partial |
41 |
Partially correct |
1697 ms |
16980 KB |
partial |
42 |
Execution timed out |
4512 ms |
11188 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
4 ms |
2652 KB |
partial |
2 |
Correct |
1 ms |
2488 KB |
ok |
3 |
Correct |
1 ms |
2652 KB |
ok |
4 |
Correct |
1 ms |
2652 KB |
ok |
5 |
Correct |
1 ms |
2652 KB |
ok |
6 |
Correct |
1 ms |
2392 KB |
ok |
7 |
Correct |
1 ms |
2652 KB |
ok |
8 |
Correct |
2 ms |
2908 KB |
ok |
9 |
Correct |
13 ms |
5976 KB |
ok |
10 |
Correct |
201 ms |
45720 KB |
ok |
11 |
Partially correct |
2 ms |
2648 KB |
partial |
12 |
Partially correct |
2 ms |
2652 KB |
partial |
13 |
Partially correct |
2 ms |
2652 KB |
partial |
14 |
Partially correct |
2 ms |
2652 KB |
partial |
15 |
Partially correct |
2 ms |
2652 KB |
partial |
16 |
Correct |
2 ms |
2652 KB |
ok |
17 |
Correct |
1 ms |
2648 KB |
ok |
18 |
Partially correct |
2 ms |
2648 KB |
partial |
19 |
Partially correct |
2 ms |
2652 KB |
partial |
20 |
Partially correct |
2 ms |
2648 KB |
partial |
21 |
Correct |
2 ms |
2652 KB |
ok |
22 |
Partially correct |
14 ms |
2652 KB |
partial |
23 |
Partially correct |
8 ms |
2652 KB |
partial |
24 |
Partially correct |
7 ms |
2652 KB |
partial |
25 |
Partially correct |
6 ms |
2488 KB |
partial |
26 |
Partially correct |
5 ms |
2652 KB |
partial |
27 |
Correct |
3 ms |
2652 KB |
ok |
28 |
Correct |
3 ms |
2652 KB |
ok |
29 |
Partially correct |
4 ms |
2652 KB |
partial |
30 |
Partially correct |
4 ms |
2652 KB |
partial |
31 |
Partially correct |
3 ms |
2652 KB |
partial |
32 |
Partially correct |
5 ms |
2652 KB |
partial |
33 |
Partially correct |
8 ms |
2492 KB |
partial |
34 |
Partially correct |
6 ms |
2652 KB |
partial |
35 |
Partially correct |
1481 ms |
10720 KB |
partial |
36 |
Partially correct |
1318 ms |
6192 KB |
partial |
37 |
Partially correct |
795 ms |
3440 KB |
partial |
38 |
Partially correct |
164 ms |
2904 KB |
partial |
39 |
Correct |
235 ms |
2752 KB |
ok |
40 |
Correct |
471 ms |
3156 KB |
ok |
41 |
Partially correct |
221 ms |
2760 KB |
partial |
42 |
Partially correct |
257 ms |
2896 KB |
partial |
43 |
Partially correct |
309 ms |
2896 KB |
partial |
44 |
Partially correct |
407 ms |
3156 KB |
partial |
45 |
Partially correct |
1137 ms |
3668 KB |
partial |
46 |
Partially correct |
1697 ms |
16980 KB |
partial |
47 |
Execution timed out |
4512 ms |
11188 KB |
Time limit exceeded |
48 |
Halted |
0 ms |
0 KB |
- |