#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
int biggest_stadium(int N, vector<vector<int>> F) {
int n = N;
vector<vector<int>> a = F, next(n, vector<int>(n));
vector dp(n + 1, vector(n + 1, vector<int>(n + 1, -1)));
function<int(int, int, int, int)> f = [&] (int l, int r, int x, int y) {
int ans = 0;
if (dp[l][x][y] != -1) return dp[l][x][y];
if (x - 1 >= 0) {
for (int j = l; j <= r; j ++) {
if (a[x - 1][j]) continue;
int z = min(r, next[x - 1][j]);
ans = max(ans, f(j, z, x - 1, y) + z - j + 1);
j = z;
}
}
if (y + 1 < n) {
for (int j = l; j <= r; j ++) {
if (a[y + 1][j]) continue;
int z = min(r, next[y + 1][j]);
ans = max(ans, f(j, z, x, y + 1) + z - j + 1);
j = z;
}
}
return dp[l][x][y] = ans;
};
for (int i = 0; i < n; i ++) {
if (a[i][n - 1] == 0) next[i][n - 1] = n - 1;
else next[i][n - 1] = n - 2;
for (int j = n - 2; j >= 0; j --) {
if (a[i][j]) next[i][j] = j - 1;
else next[i][j] = next[i][j + 1];
}
}
int ans = 0;
for (int i = 0; i < n; i ++) {
for (int j = 0; j < n; j ++) {
if (a[i][j]) continue;
ans = max(ans, f(j, next[i][j], i, i) + next[i][j] - j + 1);
j = next[i][j];
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
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 |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
3 ms |
4956 KB |
ok |
8 |
Correct |
198 ms |
506768 KB |
ok |
9 |
Runtime error |
1133 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 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 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 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 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
1 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
344 KB |
ok |
25 |
Correct |
1 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
440 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
1 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
440 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
0 ms |
604 KB |
ok |
31 |
Correct |
0 ms |
604 KB |
ok |
32 |
Correct |
0 ms |
604 KB |
ok |
33 |
Correct |
0 ms |
604 KB |
ok |
34 |
Correct |
1 ms |
600 KB |
ok |
35 |
Correct |
0 ms |
604 KB |
ok |
36 |
Correct |
0 ms |
604 KB |
ok |
37 |
Correct |
1 ms |
604 KB |
ok |
38 |
Correct |
0 ms |
604 KB |
ok |
39 |
Correct |
0 ms |
604 KB |
ok |
40 |
Correct |
0 ms |
604 KB |
ok |
41 |
Correct |
0 ms |
604 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
1 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
440 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
0 ms |
604 KB |
ok |
31 |
Correct |
0 ms |
604 KB |
ok |
32 |
Correct |
0 ms |
604 KB |
ok |
33 |
Correct |
0 ms |
604 KB |
ok |
34 |
Correct |
1 ms |
600 KB |
ok |
35 |
Correct |
0 ms |
604 KB |
ok |
36 |
Correct |
0 ms |
604 KB |
ok |
37 |
Correct |
1 ms |
604 KB |
ok |
38 |
Correct |
0 ms |
604 KB |
ok |
39 |
Correct |
0 ms |
604 KB |
ok |
40 |
Correct |
0 ms |
604 KB |
ok |
41 |
Correct |
0 ms |
604 KB |
ok |
42 |
Correct |
281 ms |
506708 KB |
ok |
43 |
Correct |
253 ms |
506748 KB |
ok |
44 |
Correct |
397 ms |
506904 KB |
ok |
45 |
Correct |
441 ms |
506748 KB |
ok |
46 |
Correct |
301 ms |
506804 KB |
ok |
47 |
Correct |
215 ms |
506912 KB |
ok |
48 |
Correct |
225 ms |
507220 KB |
ok |
49 |
Correct |
220 ms |
506948 KB |
ok |
50 |
Correct |
877 ms |
506960 KB |
ok |
51 |
Correct |
244 ms |
506964 KB |
ok |
52 |
Correct |
210 ms |
506740 KB |
ok |
53 |
Correct |
219 ms |
506704 KB |
ok |
54 |
Correct |
209 ms |
506964 KB |
ok |
55 |
Correct |
221 ms |
506788 KB |
ok |
56 |
Correct |
222 ms |
506880 KB |
ok |
57 |
Correct |
282 ms |
506840 KB |
ok |
58 |
Correct |
247 ms |
506792 KB |
ok |
59 |
Correct |
249 ms |
506964 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
3 ms |
4956 KB |
ok |
9 |
Correct |
198 ms |
506768 KB |
ok |
10 |
Runtime error |
1133 ms |
2097152 KB |
Execution killed with signal 9 |
11 |
Halted |
0 ms |
0 KB |
- |