#include "soccer.h"
using namespace std;
int biggest_stadium(int n, vector<vector<int>> f)
{
vector<vector<int>> a(n+2, vector<int>(n+2, 1));
vector<vector<int>> u(n+2, vector<int>(n+2, 0));// how many empty up
vector<vector<int>> l(n+2, vector<int>(n+2, 0));// left
vector<vector<int>> r(n+2, vector<int>(n+2, 0));// right
vector<vector<int>> d(n+2, vector<int>(n+2, 0));// down
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
a[i+1][j+1] = f[i][j];
}
}
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
if (a[i][j]) continue;
l[i][j] = l[i][j - 1] + 1;
u[i][j] = u[i - 1][j] + 1;
}
}
for (int i = n; i >= 1; i--){
for (int j = n; j >= 1; j--){
if (a[i][j]) continue;
r[i][j] = r[i][j + 1] + 1;
d[i][j] = d[i + 1][j] + 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++){
for (int j = 1; j <= n; j++){
if (a[i][j]) continue;
int siz = 0;
int up = u[i][j];
int dw = d[i][j];
for (int k = j; k < j + r[i][j]; k++){
up = min(up, u[i][k]);
dw = min(dw, d[i][k]);
siz += up + dw - 1;
}
up = u[i][j];
dw = d[i][j];
for (int k = j; k > j - l[i][j]; k--){
up = min(up, u[i][k]);
dw = min(dw, d[i][k]);
siz += up + dw - 1;
}
ans = max(ans, siz - u[i][j] - d[i][j] + 1);
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
# |
Verdict |
Execution time |
Memory |
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 |
2 ms |
604 KB |
ok |
8 |
Correct |
155 ms |
7396 KB |
ok |
9 |
Execution timed out |
4517 ms |
110416 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
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 |
Incorrect |
0 ms |
348 KB |
wrong |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
wrong |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
Incorrect |
0 ms |
348 KB |
wrong |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
2 ms |
604 KB |
ok |
9 |
Correct |
155 ms |
7396 KB |
ok |
10 |
Execution timed out |
4517 ms |
110416 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |