#include <bits/stdc++.h>
using namespace std;
int prx[2001][2001];
int pry[2001][2001];
int biggest_stadium(int n, vector<vector<int>> a){
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
prx[i+1][j+1] = prx[i][j+1] + a[i][j];
pry[i+1][j+1] = pry[i+1][j] + a[i][j];
}
}
vector<int> minx(n, n+1), maxx(n,0), miny(n, n+1), maxy(n, 0);
int cnt = 0;
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
cnt+=!a[i][j];
if (a[i][j]) continue;
minx[i] = min(minx[i], j);
maxx[i] = max(maxx[i], j);
miny[j] = min(miny[j], i);
maxy[j] = max(maxy[j], i);
}
}
for (int i=0; i<n; i++){
if (minx[i]==n+1) continue;
if (pry[i+1][maxx[i]+1] - pry[i+1][minx[i]] > 0) return -1;
}
for (int j=0; j<n; j++){
if (miny[j] ==n+1) continue;
if (prx[maxy[j]+1][j+1] - prx[miny[j]][j+1] > 0) return -1;
}
for (int i=0; i<n; i++){
minx[i] = n+1; maxx[i] = -1; maxy[i] = -1; miny[i] = n+1;
}
for (int i=0; i<n; i++){
int st = 0;
for (int j=0; j<n; j++){
if (a[i][j]){
if (!st) minx[i] = j;
if (st && maxx[i] == -1) maxx[i] = j;
} else st = 1;
}
}
for (int j=0; j<n; j++){
int st = 0;
for (int i=0; i<n; i++){
if (a[i][j]){
if (!st) miny[j] =i;
if (st && maxy[j] == -1) maxy[j] = i;
} else st = 1;
}
}
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
if (a[i][j]) continue;
for (auto [x,y]: vector<pair<int,int>> {{miny[j],minx[i]}, {miny[j],maxx[i]}, {maxy[j],maxx[i]}, {maxy[j], minx[i]} }){
if (x==-1 || x==n+1 || y==-1 || y==n+1) continue;
if (!a[x][y]) return -1;
}
}
}
return cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
# |
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 |
Partially correct |
0 ms |
600 KB |
partial |
7 |
Partially correct |
1 ms |
1372 KB |
partial |
8 |
Partially correct |
19 ms |
10076 KB |
partial |
9 |
Partially correct |
252 ms |
63024 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
0 ms |
348 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Incorrect |
1 ms |
348 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Incorrect |
1 ms |
348 KB |
wrong |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
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 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Incorrect |
1 ms |
348 KB |
wrong |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
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 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Incorrect |
1 ms |
348 KB |
wrong |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
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 |
Partially correct |
0 ms |
600 KB |
partial |
8 |
Partially correct |
1 ms |
1372 KB |
partial |
9 |
Partially correct |
19 ms |
10076 KB |
partial |
10 |
Partially correct |
252 ms |
63024 KB |
partial |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Incorrect |
1 ms |
348 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |