#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
const int MAX = 2005;
int n, a[MAX][MAX];
int L[MAX][MAX];
int R[MAX][MAX];
int go[MAX][MAX];
int res;
map<array<int, 5>, bool> was;
void rec(int xl, int xr, int yl, int yr, int side, int cur) {
if (was[{xl, xr, yl, yr, cur}]) {
return;
}
res = max(res, cur);
was[{xl, xr, yl, yr, cur}] = true;
vector<array<int, 5>> f;
if (xl > 0) {
// up
int ptr = yl;
while (ptr <= yr) {
if (a[xl - 1][ptr] == 1) {
ptr = go[xl - 1][ptr];
continue;
}
int t = min(yr, R[xl - 1][ptr]);
f.push_back({t - ptr, xl - 1, xr, ptr, t});
//rec(xl - 1, xr, ptr, t, 1, cur + t - ptr + 1);
ptr = R[xl - 1][ptr] + 1;
}
}
if (xr + 1 < n) {
// down
int ptr = yl;
while (ptr <= yr) {
if (a[xr + 1][ptr] == 1) {
ptr = go[xr + 1][ptr];
continue;
}
int t = min(yr, R[xr + 1][ptr]);
f.push_back({t - ptr, xl, xr + 1, ptr, t});
//rec(xl, xr + 1, ptr, t, 0, cur + t - ptr + 1);
ptr = R[xr + 1][ptr] + 1;
}
}
sort(f.rbegin(), f.rend());
for (auto& p : f) {
int sd = (p[1] == xl ? 0 : 1);
rec(p[1], p[2], p[3], p[4], sd, cur + p[4] - p[3] + 1);
}
}
int biggest_stadium(int N, vector<vector<int>> F) {
n = N;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
a[i][j] = F[i][j];
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[i][j] == 1) {
continue;
}
int p = j;
while (p + 1 < n && a[i][p + 1] == 0) {
p += 1;
}
for (int k = j; k <= p; k++) {
L[i][k] = j;
R[i][k] = p;
}
j = p;
}
}
for (int i = 0; i < n; i++) {
for (int j = n - 1; j >= 0; j--) {
if (a[i][j] == 1) {
go[i][j] = (j == n - 1 ? n : go[i][j + 1]);
} else {
go[i][j] = j;
}
}
}
res = 0;
vector<array<int, 4>> s;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (a[i][j] == 1) {
continue;
}
if (j == 0 || a[i][j - 1] == 1) {
s.push_back({R[i][j] - j + 1, i, j, R[i][j]});
}
}
}
sort(s.rbegin(), s.rend());
for (auto& p : s) {
int i = p[1];
int l = p[2], r = p[3];
rec(i, i, l, r, -1, r - l + 1);
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
ok |
2 |
Correct |
1 ms |
6492 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6492 KB |
ok |
5 |
Correct |
1 ms |
6492 KB |
ok |
6 |
Correct |
1 ms |
6592 KB |
ok |
7 |
Correct |
78 ms |
21844 KB |
ok |
8 |
Execution timed out |
4611 ms |
318336 KB |
Time limit exceeded |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6488 KB |
ok |
2 |
Correct |
1 ms |
6492 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6488 KB |
ok |
5 |
Correct |
1 ms |
6492 KB |
ok |
6 |
Correct |
1 ms |
6492 KB |
ok |
7 |
Correct |
1 ms |
6488 KB |
ok |
8 |
Correct |
1 ms |
6492 KB |
ok |
9 |
Correct |
1 ms |
6492 KB |
ok |
10 |
Correct |
1 ms |
6492 KB |
ok |
11 |
Correct |
1 ms |
6492 KB |
ok |
12 |
Correct |
1 ms |
6492 KB |
ok |
13 |
Correct |
1 ms |
6492 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
ok |
2 |
Correct |
1 ms |
6488 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6492 KB |
ok |
5 |
Correct |
1 ms |
6488 KB |
ok |
6 |
Correct |
1 ms |
6492 KB |
ok |
7 |
Correct |
1 ms |
6492 KB |
ok |
8 |
Correct |
1 ms |
6488 KB |
ok |
9 |
Correct |
1 ms |
6492 KB |
ok |
10 |
Correct |
1 ms |
6492 KB |
ok |
11 |
Correct |
1 ms |
6492 KB |
ok |
12 |
Correct |
1 ms |
6492 KB |
ok |
13 |
Correct |
1 ms |
6492 KB |
ok |
14 |
Correct |
1 ms |
6492 KB |
ok |
15 |
Correct |
1 ms |
6492 KB |
ok |
16 |
Correct |
1 ms |
6492 KB |
ok |
17 |
Correct |
1 ms |
6492 KB |
ok |
18 |
Correct |
1 ms |
6492 KB |
ok |
19 |
Correct |
1 ms |
6492 KB |
ok |
20 |
Correct |
1 ms |
6488 KB |
ok |
21 |
Correct |
1 ms |
6492 KB |
ok |
22 |
Correct |
1 ms |
6592 KB |
ok |
23 |
Correct |
1 ms |
6488 KB |
ok |
24 |
Correct |
1 ms |
6492 KB |
ok |
25 |
Correct |
1 ms |
6492 KB |
ok |
26 |
Correct |
1 ms |
6492 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
ok |
2 |
Correct |
1 ms |
6488 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6492 KB |
ok |
5 |
Correct |
1 ms |
6492 KB |
ok |
6 |
Correct |
1 ms |
6492 KB |
ok |
7 |
Correct |
1 ms |
6488 KB |
ok |
8 |
Correct |
1 ms |
6492 KB |
ok |
9 |
Correct |
1 ms |
6492 KB |
ok |
10 |
Correct |
1 ms |
6488 KB |
ok |
11 |
Correct |
1 ms |
6492 KB |
ok |
12 |
Correct |
1 ms |
6492 KB |
ok |
13 |
Correct |
1 ms |
6492 KB |
ok |
14 |
Correct |
1 ms |
6492 KB |
ok |
15 |
Correct |
1 ms |
6492 KB |
ok |
16 |
Correct |
1 ms |
6492 KB |
ok |
17 |
Correct |
1 ms |
6492 KB |
ok |
18 |
Correct |
1 ms |
6492 KB |
ok |
19 |
Correct |
1 ms |
6492 KB |
ok |
20 |
Correct |
1 ms |
6492 KB |
ok |
21 |
Correct |
1 ms |
6492 KB |
ok |
22 |
Correct |
1 ms |
6488 KB |
ok |
23 |
Correct |
1 ms |
6492 KB |
ok |
24 |
Correct |
1 ms |
6592 KB |
ok |
25 |
Correct |
1 ms |
6488 KB |
ok |
26 |
Correct |
1 ms |
6492 KB |
ok |
27 |
Correct |
1 ms |
6492 KB |
ok |
28 |
Correct |
1 ms |
6492 KB |
ok |
29 |
Correct |
1 ms |
6492 KB |
ok |
30 |
Correct |
27 ms |
13876 KB |
ok |
31 |
Correct |
10 ms |
11864 KB |
ok |
32 |
Correct |
2 ms |
10844 KB |
ok |
33 |
Correct |
1 ms |
10588 KB |
ok |
34 |
Correct |
8 ms |
11608 KB |
ok |
35 |
Correct |
6 ms |
11352 KB |
ok |
36 |
Correct |
2 ms |
10844 KB |
ok |
37 |
Correct |
2 ms |
10844 KB |
ok |
38 |
Correct |
3 ms |
11100 KB |
ok |
39 |
Correct |
4 ms |
11100 KB |
ok |
40 |
Correct |
5 ms |
11356 KB |
ok |
41 |
Correct |
12 ms |
12128 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
ok |
2 |
Correct |
1 ms |
6488 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6492 KB |
ok |
5 |
Correct |
1 ms |
6492 KB |
ok |
6 |
Correct |
1 ms |
6492 KB |
ok |
7 |
Correct |
1 ms |
6488 KB |
ok |
8 |
Correct |
1 ms |
6492 KB |
ok |
9 |
Correct |
1 ms |
6492 KB |
ok |
10 |
Correct |
1 ms |
6488 KB |
ok |
11 |
Correct |
1 ms |
6492 KB |
ok |
12 |
Correct |
1 ms |
6492 KB |
ok |
13 |
Correct |
1 ms |
6492 KB |
ok |
14 |
Correct |
1 ms |
6492 KB |
ok |
15 |
Correct |
1 ms |
6492 KB |
ok |
16 |
Correct |
1 ms |
6492 KB |
ok |
17 |
Correct |
1 ms |
6492 KB |
ok |
18 |
Correct |
1 ms |
6492 KB |
ok |
19 |
Correct |
1 ms |
6492 KB |
ok |
20 |
Correct |
1 ms |
6492 KB |
ok |
21 |
Correct |
1 ms |
6492 KB |
ok |
22 |
Correct |
1 ms |
6488 KB |
ok |
23 |
Correct |
1 ms |
6492 KB |
ok |
24 |
Correct |
1 ms |
6592 KB |
ok |
25 |
Correct |
1 ms |
6488 KB |
ok |
26 |
Correct |
1 ms |
6492 KB |
ok |
27 |
Correct |
1 ms |
6492 KB |
ok |
28 |
Correct |
1 ms |
6492 KB |
ok |
29 |
Correct |
1 ms |
6492 KB |
ok |
30 |
Correct |
27 ms |
13876 KB |
ok |
31 |
Correct |
10 ms |
11864 KB |
ok |
32 |
Correct |
2 ms |
10844 KB |
ok |
33 |
Correct |
1 ms |
10588 KB |
ok |
34 |
Correct |
8 ms |
11608 KB |
ok |
35 |
Correct |
6 ms |
11352 KB |
ok |
36 |
Correct |
2 ms |
10844 KB |
ok |
37 |
Correct |
2 ms |
10844 KB |
ok |
38 |
Correct |
3 ms |
11100 KB |
ok |
39 |
Correct |
4 ms |
11100 KB |
ok |
40 |
Correct |
5 ms |
11356 KB |
ok |
41 |
Correct |
12 ms |
12128 KB |
ok |
42 |
Execution timed out |
4539 ms |
515408 KB |
Time limit exceeded |
43 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
6744 KB |
ok |
2 |
Correct |
1 ms |
6488 KB |
ok |
3 |
Correct |
1 ms |
6492 KB |
ok |
4 |
Correct |
1 ms |
6492 KB |
ok |
5 |
Correct |
1 ms |
6492 KB |
ok |
6 |
Correct |
1 ms |
6492 KB |
ok |
7 |
Correct |
1 ms |
6592 KB |
ok |
8 |
Correct |
78 ms |
21844 KB |
ok |
9 |
Execution timed out |
4611 ms |
318336 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |