#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int biggest_stadium(int N, std::vector<std::vector<int>> C) {
vector<vector<int>> S(N);
auto fS = [&](int x, int y) {
if (x < 0 || y < 0) {
return 0;
}
return S[x][y];
};
auto sm = [&](int x1, int x2, int y1, int y2) -> int {
return fS(x2, y2) - fS(x1 - 1, y2) - fS(x2, y1 - 1) + fS(x1 - 1, y1 - 1);
};
for (int i = 0; i < N; i++) {
S[i] = vector<int>(N);
for (int j = 0; j < N; j++) {
S[i][j] = C[i][j];
S[i][j] += fS(i - 1, j) + fS(i, j - 1) - fS(i - 1, j - 1);
}
}
int best = 0;
for (int x = 0; x < N; x++) {
for (int y = 0; y < N; y++) {
if (C[x][y] == 1) {
continue;
}
int x0 = x;
int x1 = x;
int y0 = y;
int y1 = y;
while (x0 - 1 >= 0 && C[x0 - 1][y] == 0) {
x0--;
}
while (x1 + 1 < N && C[x1 + 1][y] == 0) {
x1++;
}
while (y0 - 1 >= 0 && C[x][y0 - 1] == 0) {
y0--;
}
while (y1 + 1 < N && C[x][y1 + 1] == 0) {
y1++;
}
int p = 0;
int mx = y1;
int mn = y0;
for (int i = x; i <= x1; i++) {
while (sm(i, i, y, mx) != 0) {
mx--;
}
while (sm(i, i, mn, y) != 0) {
mn++;
}
p += mx - mn + 1;
// cout<<i<<" "<<mn<<" "<<mx<<endl;
}
mx = y1;
mn = y0;
for (int i = x - 1; i >= x0; i--) {
while (sm(i, i, y, mx) != 0) {
mx--;
}
while (sm(i, i, mn, y) != 0) {
mn++;
}
p += mx - mn + 1;
// cout<<i<<" "<<mn<<" "<<mx<<endl;
}
// cout<<endl;
best = max(best, p);
}
}
return best;
}
//int main() {
// std::cout << biggest_stadium(3, {{1, 0, 0},
// {0, 0, 1},
// {1, 0, 1}}) << std::endl;
// return 0;
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
588 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
8 ms |
348 KB |
ok |
8 |
Correct |
924 ms |
3888 KB |
ok |
9 |
Execution timed out |
4539 ms |
55192 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
1 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Incorrect |
0 ms |
348 KB |
wrong |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Incorrect |
0 ms |
348 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
588 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
8 ms |
348 KB |
ok |
9 |
Correct |
924 ms |
3888 KB |
ok |
10 |
Execution timed out |
4539 ms |
55192 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |