#include "soccer.h"
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
int top[2005][2005];
int bottom[2005][2005];
int rangetop[2005][2005], rangebottom[2005][2005];
int f[2005][2005];
const int inf = -100000000;
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
if (F[i][j]) {
top[i][j] = N;
} else if (i == 0 || F[i-1][j]) {
top[i][j] = i;
} else {
top[i][j] = top[i-1][j];
}
}
}
for (int i = N - 1; i >= 0; i--) {
for (int j = 0; j < N; j++) {
if (F[i][j]) {
bottom[i][j] = -1;
} else if (i == N - 1 || F[i+1][j]) {
bottom[i][j] = i;
} else {
bottom[i][j] = bottom[i+1][j];
}
}
}
int ans = 0;
for (int mrow = 0; mrow < N; mrow++) {
if (N > 500 && mrow != 0 && mrow != N - 1) continue;
for (int i = 0; i < N; i++) {
rangetop[i][i] = top[mrow][i];
rangebottom[i][i] = bottom[mrow][i];
f[i][i] = bottom[mrow][i] - top[mrow][i] + 1;
if (f[i][i] < 0) f[i][i] = -inf;
}
for (int siz = 2; siz <= N; siz++) {
for (int i = 0; i <= N - siz; i++) {
rangetop[i][i+siz-1] = max(rangetop[i+1][i+siz-1], top[mrow][i]);
rangebottom[i][i+siz-1] = min(rangebottom[i+1][i+siz-1], bottom[mrow][i]);
if (rangetop[i][i+siz-1] > rangebottom[i][i+siz-1]) {
f[i][i+siz-1] = -inf;
} else {
f[i][i+siz-1] = max(f[i+1][i+siz-1], f[i][i+siz-2]) + rangebottom[i][i+siz-1] - rangetop[i][i+siz-1] + 1;
ans = max(ans, f[i][i+siz-1]);
}
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8696 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Incorrect |
1 ms |
8540 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8540 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Correct |
1 ms |
8540 KB |
ok |
6 |
Correct |
1 ms |
8632 KB |
ok |
7 |
Correct |
1 ms |
8540 KB |
ok |
8 |
Correct |
1 ms |
8540 KB |
ok |
9 |
Correct |
1 ms |
8548 KB |
ok |
10 |
Correct |
1 ms |
8624 KB |
ok |
11 |
Correct |
1 ms |
8540 KB |
ok |
12 |
Correct |
1 ms |
8540 KB |
ok |
13 |
Correct |
1 ms |
8540 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8696 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Correct |
1 ms |
8540 KB |
ok |
6 |
Correct |
1 ms |
8540 KB |
ok |
7 |
Correct |
1 ms |
8632 KB |
ok |
8 |
Correct |
1 ms |
8540 KB |
ok |
9 |
Correct |
1 ms |
8540 KB |
ok |
10 |
Correct |
1 ms |
8548 KB |
ok |
11 |
Correct |
1 ms |
8624 KB |
ok |
12 |
Correct |
1 ms |
8540 KB |
ok |
13 |
Correct |
1 ms |
8540 KB |
ok |
14 |
Correct |
1 ms |
8540 KB |
ok |
15 |
Correct |
1 ms |
8536 KB |
ok |
16 |
Correct |
1 ms |
8540 KB |
ok |
17 |
Correct |
1 ms |
8540 KB |
ok |
18 |
Correct |
1 ms |
8540 KB |
ok |
19 |
Correct |
1 ms |
8540 KB |
ok |
20 |
Correct |
1 ms |
8540 KB |
ok |
21 |
Correct |
1 ms |
8540 KB |
ok |
22 |
Correct |
1 ms |
8540 KB |
ok |
23 |
Correct |
1 ms |
8540 KB |
ok |
24 |
Correct |
2 ms |
8540 KB |
ok |
25 |
Correct |
1 ms |
8540 KB |
ok |
26 |
Correct |
1 ms |
8540 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8696 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Correct |
1 ms |
8540 KB |
ok |
6 |
Correct |
1 ms |
8540 KB |
ok |
7 |
Correct |
1 ms |
8540 KB |
ok |
8 |
Correct |
1 ms |
8540 KB |
ok |
9 |
Correct |
1 ms |
8632 KB |
ok |
10 |
Correct |
1 ms |
8540 KB |
ok |
11 |
Correct |
1 ms |
8540 KB |
ok |
12 |
Correct |
1 ms |
8548 KB |
ok |
13 |
Correct |
1 ms |
8624 KB |
ok |
14 |
Correct |
1 ms |
8540 KB |
ok |
15 |
Correct |
1 ms |
8540 KB |
ok |
16 |
Correct |
1 ms |
8540 KB |
ok |
17 |
Correct |
1 ms |
8536 KB |
ok |
18 |
Correct |
1 ms |
8540 KB |
ok |
19 |
Correct |
1 ms |
8540 KB |
ok |
20 |
Correct |
1 ms |
8540 KB |
ok |
21 |
Correct |
1 ms |
8540 KB |
ok |
22 |
Correct |
1 ms |
8540 KB |
ok |
23 |
Correct |
1 ms |
8540 KB |
ok |
24 |
Correct |
1 ms |
8540 KB |
ok |
25 |
Correct |
1 ms |
8540 KB |
ok |
26 |
Correct |
2 ms |
8540 KB |
ok |
27 |
Correct |
1 ms |
8540 KB |
ok |
28 |
Correct |
1 ms |
8540 KB |
ok |
29 |
Correct |
1 ms |
8540 KB |
ok |
30 |
Correct |
1 ms |
8540 KB |
ok |
31 |
Correct |
1 ms |
8540 KB |
ok |
32 |
Correct |
1 ms |
8540 KB |
ok |
33 |
Correct |
1 ms |
8540 KB |
ok |
34 |
Correct |
1 ms |
8624 KB |
ok |
35 |
Correct |
1 ms |
8540 KB |
ok |
36 |
Correct |
1 ms |
8540 KB |
ok |
37 |
Correct |
1 ms |
8540 KB |
ok |
38 |
Correct |
1 ms |
8540 KB |
ok |
39 |
Correct |
1 ms |
8540 KB |
ok |
40 |
Correct |
1 ms |
8540 KB |
ok |
41 |
Correct |
1 ms |
8540 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8696 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Correct |
1 ms |
8540 KB |
ok |
6 |
Correct |
1 ms |
8540 KB |
ok |
7 |
Correct |
1 ms |
8540 KB |
ok |
8 |
Correct |
1 ms |
8540 KB |
ok |
9 |
Correct |
1 ms |
8632 KB |
ok |
10 |
Correct |
1 ms |
8540 KB |
ok |
11 |
Correct |
1 ms |
8540 KB |
ok |
12 |
Correct |
1 ms |
8548 KB |
ok |
13 |
Correct |
1 ms |
8624 KB |
ok |
14 |
Correct |
1 ms |
8540 KB |
ok |
15 |
Correct |
1 ms |
8540 KB |
ok |
16 |
Correct |
1 ms |
8540 KB |
ok |
17 |
Correct |
1 ms |
8536 KB |
ok |
18 |
Correct |
1 ms |
8540 KB |
ok |
19 |
Correct |
1 ms |
8540 KB |
ok |
20 |
Correct |
1 ms |
8540 KB |
ok |
21 |
Correct |
1 ms |
8540 KB |
ok |
22 |
Correct |
1 ms |
8540 KB |
ok |
23 |
Correct |
1 ms |
8540 KB |
ok |
24 |
Correct |
1 ms |
8540 KB |
ok |
25 |
Correct |
1 ms |
8540 KB |
ok |
26 |
Correct |
2 ms |
8540 KB |
ok |
27 |
Correct |
1 ms |
8540 KB |
ok |
28 |
Correct |
1 ms |
8540 KB |
ok |
29 |
Correct |
1 ms |
8540 KB |
ok |
30 |
Correct |
1 ms |
8540 KB |
ok |
31 |
Correct |
1 ms |
8540 KB |
ok |
32 |
Correct |
1 ms |
8540 KB |
ok |
33 |
Correct |
1 ms |
8540 KB |
ok |
34 |
Correct |
1 ms |
8624 KB |
ok |
35 |
Correct |
1 ms |
8540 KB |
ok |
36 |
Correct |
1 ms |
8540 KB |
ok |
37 |
Correct |
1 ms |
8540 KB |
ok |
38 |
Correct |
1 ms |
8540 KB |
ok |
39 |
Correct |
1 ms |
8540 KB |
ok |
40 |
Correct |
1 ms |
8540 KB |
ok |
41 |
Correct |
1 ms |
8540 KB |
ok |
42 |
Correct |
194 ms |
31856 KB |
ok |
43 |
Correct |
194 ms |
31860 KB |
ok |
44 |
Correct |
206 ms |
31864 KB |
ok |
45 |
Correct |
215 ms |
31632 KB |
ok |
46 |
Correct |
192 ms |
31836 KB |
ok |
47 |
Correct |
239 ms |
31856 KB |
ok |
48 |
Correct |
202 ms |
31836 KB |
ok |
49 |
Correct |
212 ms |
32084 KB |
ok |
50 |
Correct |
229 ms |
31832 KB |
ok |
51 |
Correct |
193 ms |
31836 KB |
ok |
52 |
Correct |
195 ms |
31836 KB |
ok |
53 |
Correct |
190 ms |
31856 KB |
ok |
54 |
Correct |
189 ms |
31836 KB |
ok |
55 |
Correct |
195 ms |
31836 KB |
ok |
56 |
Correct |
204 ms |
31836 KB |
ok |
57 |
Correct |
223 ms |
32080 KB |
ok |
58 |
Correct |
244 ms |
31836 KB |
ok |
59 |
Correct |
221 ms |
31640 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
8696 KB |
ok |
2 |
Correct |
1 ms |
8540 KB |
ok |
3 |
Correct |
1 ms |
8540 KB |
ok |
4 |
Correct |
1 ms |
8540 KB |
ok |
5 |
Correct |
1 ms |
8540 KB |
ok |
6 |
Incorrect |
1 ms |
8540 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |