#include <bits/stdc++.h>
using namespace std;
int prx[2001][2001];
int pry[2001][2001];
int TestCase1(int n, vector<vector<int>> a){
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
if (!a[i][j]) continue;
int h = min(i+1, n-i);
int v = min(j+1, n-j);
return n*n-h*v;
}
}
return n*n;
}
int TestCase2(int n, vector<vector<int>> a1){
int ans = 1;
auto a = a1;
for (int cd = 0; cd<(1<<(n*n)); cd++){
a = a1;
int bad = 0;
for (int i=0; i<n; i++) for (int j=0; j<n; j++)
if (a[i][j] && !(cd&(1<<(n*i+j)))) bad = 1;
if (bad) continue;
for (int i=0; i<n; i++) for (int j=0; j<n; j++) a[i][j] = (bool) (cd & (1<<(n*i+j)));
for (int x1 = 0; x1<n; x1++) for (int y1 = 0; y1<n; y1++){
if (a[x1][y1]) continue;
for (int x2 = 0; x2<n; x2++) for (int y2 = 0; y2<n; y2++){
if (a[x2][y2]) continue;
if (x1==x2 && y1==y2) continue;
if (x1 == x2){
for (int j=min(y1,y2); j<max(y1,y2); j ++){
if (a[x1][j]) bad = 1;
}
}
if (y1 == y2){
for (int i=min(x1,x2); i<max(x1,x2); i++){
if (a[i][y1]) bad =1;
}
}
if (a[x1][y2] && a[x2][y1]) bad = 1;
if (bad) break;
}
if (bad) break;
}
if (bad) continue;
ans = max(ans, n*n - __builtin_popcount(cd));
}
return ans;
}
int Partial(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 i=0; i<n; i++){
for (int j=i+1; j<n; j++){
int x1 = minx[i], y1 = maxx[i], x2 = minx[j], y2 = maxx[j];
if (x1>x2) swap(x1,x2), swap(y1,y2);
if (x1==x2) continue;
if (y1<y2) return -1;
}
}
return cnt;
}
int biggest_stadium(int n, vector<vector<int>> a){
if (n<4) return TestCase2(n,a);
int ones = 0;
for(int i=0; i<n; i++) for (int j=0; j<n; j++) ones+=a[i][j];
if (ones<=1) return TestCase1(n,a);
return Partial(n,a);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
496 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
544 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
600 KB |
ok |
7 |
Correct |
1 ms |
344 KB |
ok |
8 |
Correct |
16 ms |
3664 KB |
ok |
9 |
Correct |
234 ms |
51488 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
1 ms |
544 KB |
ok |
3 |
Correct |
0 ms |
344 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
600 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
1 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
1 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
496 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
544 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
600 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
1 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
1 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Partially correct |
0 ms |
344 KB |
partial |
16 |
Partially correct |
0 ms |
344 KB |
partial |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
1 ms |
356 KB |
partial |
20 |
Correct |
1 ms |
344 KB |
ok |
21 |
Correct |
1 ms |
344 KB |
ok |
22 |
Partially correct |
0 ms |
600 KB |
partial |
23 |
Partially correct |
0 ms |
344 KB |
partial |
24 |
Partially correct |
0 ms |
344 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
344 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
496 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
544 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
600 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
1 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
1 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Partially correct |
0 ms |
344 KB |
partial |
18 |
Partially correct |
0 ms |
344 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
1 ms |
356 KB |
partial |
22 |
Correct |
1 ms |
344 KB |
ok |
23 |
Correct |
1 ms |
344 KB |
ok |
24 |
Partially correct |
0 ms |
600 KB |
partial |
25 |
Partially correct |
0 ms |
344 KB |
partial |
26 |
Partially correct |
0 ms |
344 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
344 KB |
partial |
29 |
Partially correct |
0 ms |
344 KB |
partial |
30 |
Partially correct |
1 ms |
600 KB |
partial |
31 |
Partially correct |
1 ms |
604 KB |
partial |
32 |
Partially correct |
0 ms |
600 KB |
partial |
33 |
Partially correct |
1 ms |
600 KB |
partial |
34 |
Correct |
1 ms |
600 KB |
ok |
35 |
Correct |
1 ms |
600 KB |
ok |
36 |
Partially correct |
1 ms |
604 KB |
partial |
37 |
Partially correct |
1 ms |
600 KB |
partial |
38 |
Partially correct |
1 ms |
600 KB |
partial |
39 |
Partially correct |
1 ms |
600 KB |
partial |
40 |
Partially correct |
1 ms |
604 KB |
partial |
41 |
Partially correct |
1 ms |
600 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
496 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
544 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
344 KB |
ok |
9 |
Correct |
0 ms |
600 KB |
ok |
10 |
Correct |
0 ms |
344 KB |
ok |
11 |
Correct |
1 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
344 KB |
ok |
15 |
Correct |
1 ms |
344 KB |
ok |
16 |
Correct |
0 ms |
344 KB |
ok |
17 |
Partially correct |
0 ms |
344 KB |
partial |
18 |
Partially correct |
0 ms |
344 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
1 ms |
356 KB |
partial |
22 |
Correct |
1 ms |
344 KB |
ok |
23 |
Correct |
1 ms |
344 KB |
ok |
24 |
Partially correct |
0 ms |
600 KB |
partial |
25 |
Partially correct |
0 ms |
344 KB |
partial |
26 |
Partially correct |
0 ms |
344 KB |
partial |
27 |
Partially correct |
0 ms |
348 KB |
partial |
28 |
Partially correct |
0 ms |
344 KB |
partial |
29 |
Partially correct |
0 ms |
344 KB |
partial |
30 |
Partially correct |
1 ms |
600 KB |
partial |
31 |
Partially correct |
1 ms |
604 KB |
partial |
32 |
Partially correct |
0 ms |
600 KB |
partial |
33 |
Partially correct |
1 ms |
600 KB |
partial |
34 |
Correct |
1 ms |
600 KB |
ok |
35 |
Correct |
1 ms |
600 KB |
ok |
36 |
Partially correct |
1 ms |
604 KB |
partial |
37 |
Partially correct |
1 ms |
600 KB |
partial |
38 |
Partially correct |
1 ms |
600 KB |
partial |
39 |
Partially correct |
1 ms |
600 KB |
partial |
40 |
Partially correct |
1 ms |
604 KB |
partial |
41 |
Partially correct |
1 ms |
600 KB |
partial |
42 |
Partially correct |
18 ms |
11608 KB |
partial |
43 |
Partially correct |
19 ms |
11608 KB |
partial |
44 |
Partially correct |
23 ms |
11600 KB |
partial |
45 |
Partially correct |
18 ms |
11608 KB |
partial |
46 |
Partially correct |
17 ms |
11660 KB |
partial |
47 |
Partially correct |
18 ms |
11472 KB |
partial |
48 |
Correct |
18 ms |
11664 KB |
ok |
49 |
Partially correct |
17 ms |
11668 KB |
partial |
50 |
Partially correct |
18 ms |
11600 KB |
partial |
51 |
Partially correct |
17 ms |
11544 KB |
partial |
52 |
Partially correct |
17 ms |
11608 KB |
partial |
53 |
Partially correct |
18 ms |
11612 KB |
partial |
54 |
Partially correct |
17 ms |
11612 KB |
partial |
55 |
Partially correct |
18 ms |
11600 KB |
partial |
56 |
Partially correct |
19 ms |
12116 KB |
partial |
57 |
Partially correct |
17 ms |
11608 KB |
partial |
58 |
Partially correct |
18 ms |
11608 KB |
partial |
59 |
Partially correct |
18 ms |
11608 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
496 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
1 ms |
544 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
600 KB |
ok |
8 |
Correct |
1 ms |
344 KB |
ok |
9 |
Correct |
16 ms |
3664 KB |
ok |
10 |
Correct |
234 ms |
51488 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
0 ms |
344 KB |
ok |
13 |
Correct |
0 ms |
344 KB |
ok |
14 |
Correct |
0 ms |
600 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
1 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
0 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
344 KB |
ok |
20 |
Correct |
1 ms |
344 KB |
ok |
21 |
Correct |
0 ms |
344 KB |
ok |
22 |
Partially correct |
0 ms |
344 KB |
partial |
23 |
Partially correct |
0 ms |
344 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
356 KB |
partial |
27 |
Correct |
1 ms |
344 KB |
ok |
28 |
Correct |
1 ms |
344 KB |
ok |
29 |
Partially correct |
0 ms |
600 KB |
partial |
30 |
Partially correct |
0 ms |
344 KB |
partial |
31 |
Partially correct |
0 ms |
344 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
0 ms |
344 KB |
partial |
34 |
Partially correct |
0 ms |
344 KB |
partial |
35 |
Partially correct |
1 ms |
600 KB |
partial |
36 |
Partially correct |
1 ms |
604 KB |
partial |
37 |
Partially correct |
0 ms |
600 KB |
partial |
38 |
Partially correct |
1 ms |
600 KB |
partial |
39 |
Correct |
1 ms |
600 KB |
ok |
40 |
Correct |
1 ms |
600 KB |
ok |
41 |
Partially correct |
1 ms |
604 KB |
partial |
42 |
Partially correct |
1 ms |
600 KB |
partial |
43 |
Partially correct |
1 ms |
600 KB |
partial |
44 |
Partially correct |
1 ms |
600 KB |
partial |
45 |
Partially correct |
1 ms |
604 KB |
partial |
46 |
Partially correct |
1 ms |
600 KB |
partial |
47 |
Partially correct |
18 ms |
11608 KB |
partial |
48 |
Partially correct |
19 ms |
11608 KB |
partial |
49 |
Partially correct |
23 ms |
11600 KB |
partial |
50 |
Partially correct |
18 ms |
11608 KB |
partial |
51 |
Partially correct |
17 ms |
11660 KB |
partial |
52 |
Partially correct |
18 ms |
11472 KB |
partial |
53 |
Correct |
18 ms |
11664 KB |
ok |
54 |
Partially correct |
17 ms |
11668 KB |
partial |
55 |
Partially correct |
18 ms |
11600 KB |
partial |
56 |
Partially correct |
17 ms |
11544 KB |
partial |
57 |
Partially correct |
17 ms |
11608 KB |
partial |
58 |
Partially correct |
18 ms |
11612 KB |
partial |
59 |
Partially correct |
17 ms |
11612 KB |
partial |
60 |
Partially correct |
18 ms |
11600 KB |
partial |
61 |
Partially correct |
19 ms |
12116 KB |
partial |
62 |
Partially correct |
17 ms |
11608 KB |
partial |
63 |
Partially correct |
18 ms |
11608 KB |
partial |
64 |
Partially correct |
18 ms |
11608 KB |
partial |
65 |
Partially correct |
261 ms |
83024 KB |
partial |
66 |
Partially correct |
267 ms |
83024 KB |
partial |
67 |
Partially correct |
259 ms |
83028 KB |
partial |
68 |
Partially correct |
248 ms |
83028 KB |
partial |
69 |
Partially correct |
251 ms |
83024 KB |
partial |
70 |
Partially correct |
244 ms |
82984 KB |
partial |
71 |
Partially correct |
245 ms |
82828 KB |
partial |
72 |
Partially correct |
243 ms |
82976 KB |
partial |
73 |
Correct |
253 ms |
82976 KB |
ok |
74 |
Correct |
258 ms |
82980 KB |
ok |
75 |
Partially correct |
244 ms |
83024 KB |
partial |
76 |
Partially correct |
303 ms |
82980 KB |
partial |
77 |
Partially correct |
274 ms |
83024 KB |
partial |
78 |
Partially correct |
249 ms |
83016 KB |
partial |
79 |
Partially correct |
254 ms |
83024 KB |
partial |
80 |
Partially correct |
247 ms |
83028 KB |
partial |
81 |
Partially correct |
251 ms |
82972 KB |
partial |
82 |
Partially correct |
252 ms |
83024 KB |
partial |
83 |
Partially correct |
252 ms |
83024 KB |
partial |
84 |
Partially correct |
250 ms |
83080 KB |
partial |
85 |
Partially correct |
250 ms |
83024 KB |
partial |
86 |
Partially correct |
258 ms |
82820 KB |
partial |
87 |
Partially correct |
262 ms |
82976 KB |
partial |
88 |
Partially correct |
257 ms |
83024 KB |
partial |
89 |
Partially correct |
244 ms |
83032 KB |
partial |
90 |
Partially correct |
245 ms |
83276 KB |
partial |
91 |
Partially correct |
249 ms |
82832 KB |
partial |
92 |
Partially correct |
252 ms |
83048 KB |
partial |
93 |
Partially correct |
261 ms |
82980 KB |
partial |
94 |
Partially correct |
254 ms |
82980 KB |
partial |
95 |
Partially correct |
250 ms |
82964 KB |
partial |
96 |
Partially correct |
252 ms |
83024 KB |
partial |
97 |
Partially correct |
246 ms |
82980 KB |
partial |
98 |
Partially correct |
256 ms |
82960 KB |
partial |
99 |
Partially correct |
249 ms |
82972 KB |
partial |
100 |
Partially correct |
247 ms |
83028 KB |
partial |
101 |
Partially correct |
252 ms |
83024 KB |
partial |
102 |
Partially correct |
255 ms |
83028 KB |
partial |
103 |
Partially correct |
264 ms |
82972 KB |
partial |
104 |
Partially correct |
261 ms |
82976 KB |
partial |
105 |
Partially correct |
254 ms |
82976 KB |
partial |
106 |
Partially correct |
245 ms |
82980 KB |
partial |
107 |
Partially correct |
249 ms |
82980 KB |
partial |
108 |
Partially correct |
255 ms |
83024 KB |
partial |
109 |
Partially correct |
250 ms |
82980 KB |
partial |