#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
int n;
vector< vector<int> > a;
vector<vector<int> > R, C;
/*
5
1 1 1 1 1
1 1 1 1 1
1 0 0 0 1
1 0 0 0 1
1 0 1 0 1
*/
/*
5
1 0 0 0 0
1 0 0 0 0
0 0 0 0 0
0 0 0 0 0
1 1 1 0 0
*/
int counter(int i, int j, int x, int y){
int c = 0;
while(i >= 0 && i < n && j < n && j >= 0){
c+= (a[i][j] == 0);
i+= x, j+= y;
}
return c;
}
int row_ones(int row, int i, int j){
if(i > j) swap(i, j);
return R[row][j] - (i == 0 ? 0 : R[row][i-1]);
}
int col_ones(int col, int i, int j){
if(i > j) swap(i, j);
return C[col][j] - (i == 0 ? 0 : C[col][i-1]);
}
int check(int i, int j, int r, int c){
int ok = 0;
if(row_ones(i, j, c) + col_ones(c, i, r) > 0) ok++;
if(col_ones(j, i, r) + row_ones(r, j, c) > 0) ok++;
if(ok != 2) return 1;
return 0;
}
int biggest_stadium(int N, vector<vector<int>> F){
n = N;
a = F;
R.resize(N);
C.resize(N);
int ans = 0;
for(int i = 0;i < n; i++){
for(int j = 0;j < n; j++){
ans+= (a[i][j] == 0);
}
}
for(int i = 0;i < n; i++){
for(int j = 0;j < n; j++){
R[i].push_back((R[i].empty() ? 0 : R[i].back()) + (a[i][j] == 1));
}
// cout << i+1 << " = ";
// for(auto x : R[i]) cout << x << ' ';
// cout << '\n';
}
for(int j = 0;j < n; j++){
for(int i = 0;i < n; i++){
C[j].push_back((C[j].empty() ? 0 : C[j].back()) + (a[i][j] == 1));
}
}
if(ans == n * n) return ans;
if(n * n - ans == 1){
int mx = 0;
for(int i = 0;i < n; i++){
for(int j = 0;j < n; j++){
if(a[i][j] == 0) continue;
int west = counter(i, j, -1, 0);
int east = counter(i, j, 1, 0);
int north = counter(i, j, 0, -1);
int south = counter(i, j, 0, 1);
return ans - min(west, east)* min(north, south);
}
}
return mx;
}
for(int i = 0;i < n; i++){
for(int j = 0;j < n; j++){
for(int r = 0; r < n; r++){
for(int c = 0; c < n; c++){
if(a[i][j] == 0 and a[r][c] == 0){
if(!check(i, j, r, c)){
return 0;
}
}
}
}
}
}
return ans;
}
//main(){
// int N; cin >> N;
// vector< vector<int> > F(N, vector<int>(N));
// for(int i = 0;i < N; i++){
// for(int j = 0;j < N; j++){
// cin >> F[i][j];
// }
// }
// cout << biggest_stadium(N, F);
//}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 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 |
1 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
2 ms |
604 KB |
partial |
8 |
Partially correct |
17 ms |
5272 KB |
partial |
9 |
Partially correct |
276 ms |
79700 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 |
1 ms |
348 KB |
partial |
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 |
Partially correct |
0 ms |
512 KB |
partial |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Partially correct |
0 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
1 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
512 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
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 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Partially correct |
0 ms |
348 KB |
partial |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
344 KB |
partial |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
348 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
1 ms |
348 KB |
partial |
26 |
Partially correct |
1 ms |
348 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 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 |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 KB |
partial |
10 |
Partially correct |
0 ms |
512 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
344 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
27 |
Partially correct |
1 ms |
348 KB |
partial |
28 |
Partially correct |
1 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
1 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
1 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
2 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
1 ms |
348 KB |
partial |
38 |
Partially correct |
1 ms |
348 KB |
partial |
39 |
Partially correct |
1 ms |
348 KB |
partial |
40 |
Partially correct |
1 ms |
344 KB |
partial |
41 |
Partially correct |
0 ms |
348 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 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 |
1 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 KB |
partial |
10 |
Partially correct |
0 ms |
512 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
344 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
27 |
Partially correct |
1 ms |
348 KB |
partial |
28 |
Partially correct |
1 ms |
348 KB |
partial |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
1 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
0 ms |
348 KB |
partial |
33 |
Partially correct |
1 ms |
348 KB |
partial |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
2 ms |
348 KB |
ok |
36 |
Partially correct |
1 ms |
348 KB |
partial |
37 |
Partially correct |
1 ms |
348 KB |
partial |
38 |
Partially correct |
1 ms |
348 KB |
partial |
39 |
Partially correct |
1 ms |
348 KB |
partial |
40 |
Partially correct |
1 ms |
344 KB |
partial |
41 |
Partially correct |
0 ms |
348 KB |
partial |
42 |
Partially correct |
17 ms |
5464 KB |
partial |
43 |
Partially correct |
17 ms |
5468 KB |
partial |
44 |
Partially correct |
16 ms |
5212 KB |
partial |
45 |
Partially correct |
19 ms |
5268 KB |
partial |
46 |
Partially correct |
17 ms |
5212 KB |
partial |
47 |
Partially correct |
17 ms |
5468 KB |
partial |
48 |
Execution timed out |
4562 ms |
5212 KB |
Time limit exceeded |
49 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
348 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 |
1 ms |
344 KB |
ok |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
2 ms |
604 KB |
partial |
9 |
Partially correct |
17 ms |
5272 KB |
partial |
10 |
Partially correct |
276 ms |
79700 KB |
partial |
11 |
Partially correct |
1 ms |
348 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
512 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
348 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
344 KB |
partial |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Partially correct |
0 ms |
348 KB |
partial |
30 |
Partially correct |
0 ms |
348 KB |
partial |
31 |
Partially correct |
0 ms |
348 KB |
partial |
32 |
Partially correct |
1 ms |
348 KB |
partial |
33 |
Partially correct |
1 ms |
348 KB |
partial |
34 |
Partially correct |
0 ms |
348 KB |
partial |
35 |
Partially correct |
1 ms |
348 KB |
partial |
36 |
Partially correct |
0 ms |
348 KB |
partial |
37 |
Partially correct |
0 ms |
348 KB |
partial |
38 |
Partially correct |
1 ms |
348 KB |
partial |
39 |
Correct |
1 ms |
348 KB |
ok |
40 |
Correct |
2 ms |
348 KB |
ok |
41 |
Partially correct |
1 ms |
348 KB |
partial |
42 |
Partially correct |
1 ms |
348 KB |
partial |
43 |
Partially correct |
1 ms |
348 KB |
partial |
44 |
Partially correct |
1 ms |
348 KB |
partial |
45 |
Partially correct |
1 ms |
344 KB |
partial |
46 |
Partially correct |
0 ms |
348 KB |
partial |
47 |
Partially correct |
17 ms |
5464 KB |
partial |
48 |
Partially correct |
17 ms |
5468 KB |
partial |
49 |
Partially correct |
16 ms |
5212 KB |
partial |
50 |
Partially correct |
19 ms |
5268 KB |
partial |
51 |
Partially correct |
17 ms |
5212 KB |
partial |
52 |
Partially correct |
17 ms |
5468 KB |
partial |
53 |
Execution timed out |
4562 ms |
5212 KB |
Time limit exceeded |
54 |
Halted |
0 ms |
0 KB |
- |