#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
int n, ans = 0;
vector<vector<pair<int, int>>> segs;
map<tuple<int, int, int, int>, int> dp1;
int solve(int i1, int i2, int l, int r) {
if (dp1.find({i1, i2, l, r}) != dp1.end()) {
return dp1[{i1, i2, l, r}];
}
int v = 0;
if (i1-1 >= 0) {
for (auto [x, y] : segs[i1-1]) {
if (r < x || y < l) {
continue;
}
v = max(v, solve(i1-1, i2, max(l, x), min(r, y)));
}
}
if (i2+1 < n) {
for (auto [x, y] : segs[i2+1]) {
if (r < x || y < l) {
continue;
}
v = max(v, solve(i1, i2+1, max(l, x), min(r, y)));
}
}
dp1[{i1, i2, l, r}] = v+(r-l+1);
return v+(r-l+1);
}
int biggest_stadium(int N, vector<vector<int>> f) {
n = N;
segs.resize(n);
for (int i = 0; i < n; i++) {
int l = -1, r = -1;
for (int j = 0; j < n; j++) {
if (f[i][j] == 0) {
if (l == -1) {
l = j;
}
r = j;
} else {
if (l != -1) {
segs[i].push_back({l, r});
}
l = -1;
}
}
if (l != -1) {
segs[i].push_back({l, r});
}
}
for (int i = 0; i < n; i++) {
for (auto [x, y] : segs[i]) {
ans = max(ans, solve(i, i, x, y));
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 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 |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
2 ms |
860 KB |
ok |
8 |
Correct |
63 ms |
12172 KB |
ok |
9 |
Correct |
1027 ms |
186960 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 |
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 |
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 |
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 |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 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 |
344 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 |
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 |
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 |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 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 |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
1 ms |
348 KB |
ok |
31 |
Correct |
1 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
1 ms |
348 KB |
ok |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
0 ms |
348 KB |
ok |
36 |
Correct |
0 ms |
348 KB |
ok |
37 |
Correct |
1 ms |
348 KB |
ok |
38 |
Correct |
0 ms |
432 KB |
ok |
39 |
Correct |
0 ms |
344 KB |
ok |
40 |
Correct |
0 ms |
348 KB |
ok |
41 |
Correct |
1 ms |
448 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 |
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 |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 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 |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
1 ms |
348 KB |
ok |
31 |
Correct |
1 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
1 ms |
348 KB |
ok |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
0 ms |
348 KB |
ok |
36 |
Correct |
0 ms |
348 KB |
ok |
37 |
Correct |
1 ms |
348 KB |
ok |
38 |
Correct |
0 ms |
432 KB |
ok |
39 |
Correct |
0 ms |
344 KB |
ok |
40 |
Correct |
0 ms |
348 KB |
ok |
41 |
Correct |
1 ms |
448 KB |
ok |
42 |
Correct |
676 ms |
74580 KB |
ok |
43 |
Correct |
322 ms |
37456 KB |
ok |
44 |
Execution timed out |
4554 ms |
538828 KB |
Time limit exceeded |
45 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
2 ms |
860 KB |
ok |
9 |
Correct |
63 ms |
12172 KB |
ok |
10 |
Correct |
1027 ms |
186960 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 |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 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 |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
344 KB |
ok |
30 |
Correct |
0 ms |
348 KB |
ok |
31 |
Correct |
0 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
0 ms |
348 KB |
ok |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Correct |
1 ms |
348 KB |
ok |
37 |
Correct |
0 ms |
348 KB |
ok |
38 |
Correct |
1 ms |
348 KB |
ok |
39 |
Correct |
0 ms |
348 KB |
ok |
40 |
Correct |
0 ms |
348 KB |
ok |
41 |
Correct |
0 ms |
348 KB |
ok |
42 |
Correct |
1 ms |
348 KB |
ok |
43 |
Correct |
0 ms |
432 KB |
ok |
44 |
Correct |
0 ms |
344 KB |
ok |
45 |
Correct |
0 ms |
348 KB |
ok |
46 |
Correct |
1 ms |
448 KB |
ok |
47 |
Correct |
676 ms |
74580 KB |
ok |
48 |
Correct |
322 ms |
37456 KB |
ok |
49 |
Execution timed out |
4554 ms |
538828 KB |
Time limit exceeded |
50 |
Halted |
0 ms |
0 KB |
- |