#include "bits/stdc++.h"
//#define int long long
#define all(v) v.begin() , v.end()
#define sz(a) (int)a.size()
using namespace std;
#include "soccer.h"
//int dp[8][8][8][8][8][8];
vector<vector<int>> ar;
int ans=0,n;
const int INF = 1e7;
/*int calc(int a,int b,int c,int d,int e,int f){
if(dp[a][b][c][d][e][f]!=-1) return dp[a][b][c][d][e][f];
int cevv=0;
for(int i=b;i<=c;i++) if(ar[a][i]) return dp[a][b][c][d][e][f]=-INF;
for(int i=e;i<=f;i++) if(ar[d][i]) return dp[a][b][c][d][e][f]=-INF;
if(a>0){
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(ar[a-1][j]) break;
if(b<=i && j<=c && ((i<=e && f<=j) || (e<=i && j<=f)) ) cevv=max(cevv,calc(a-1,i,j,d,e,f)+j-i+1);
}
}
}
if(d+1<n){
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
if(ar[d+1][j]) break;
if(e<=i && j<=f && ((i<=b && c<=j) || (b<=i && j<=c)) ) cevv=max(cevv,calc(a,b,c,d+1,i,j)+j-i+1);
}
}
}
return dp[a][b][c][d][e][f]=cevv;
}*/
int biggest_stadium(int N, vector<vector<int>> xd){
//memset(dp,-1,sizeof(dp));
ar=xd;n=N;
/*if(n<=7){
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
for(int k=j;k<n;k++){
if(ar[i][k]) break;
ans=max(ans,calc(i,j,k,i,j,k)+k-j+1);
}
}
}
return ans;
}*/
array<int,2> row[n],col[n];
int ilk_row=-1,son_row=-1,ilk_col=-1,son_col=-1;
for(int i=0;i<n;i++){
array<int,2> lol={-1,-1};
for(int j=0;j<n;j++){
if(!ar[i][j]){
if(lol[0]==-1) lol={j,j};
else if(lol[1]==j-1) lol[1]++;
else return -1;
}
}
row[i]=lol;
if(ilk_row==-1 && row[i][0]!=-1) ilk_row=i;
if(row[i][0]!=-1) son_row=i;
}
for(int i=ilk_row+1;i<=son_row;i++){
bool ok=0,ok2=0;
if(row[i][0]==-1) return -1;
if(row[i][0]<=row[ilk_row][0] && row[ilk_row][1]<=row[i][1]) ok2=1;
if(row[ilk_row][0]<=row[i][0] && row[i][1]<=row[ilk_row][1]) ok2=1;
if(row[i-1][0]<=row[i][0] && row[i][1]<=row[i-1][1]) ok=1;
if(row[i][0]<=row[i-1][0] && row[i-1][1]<=row[i][1]) ok=1;
if(!ok || !ok2) return -1;
}
for(int j=0;j<n;j++){
array<int,2> lol={-1,-1};
for(int i=0;i<n;i++){
if(!ar[i][j]){
if(lol[0]==-1) lol={i,i};
else if(lol[1]==i-1) lol[1]++;
else return -1;
}
}
col[j]=lol;
if(ilk_col==-1 && col[j][0]!=-1) ilk_col=j;
if(col[j][0]!=-1) son_col=j;
}
for(int i=ilk_col+1;i<=son_col;i++){
bool ok=0,ok2=0;
if(col[i][0]==-1) return -1;
if(col[i][0]<=col[ilk_col][0] && col[ilk_col][1]<=col[i][1]) ok2=1;
if(col[ilk_col][0]<=col[i][0] && col[i][1]<=col[ilk_col][1]) ok2=1;
if(col[i-1][0]<=col[i][0] && col[i][1]<=col[i-1][1]) ok=1;
if(col[i][0]<=col[i-1][0] && col[i-1][1]<=col[i][1]) ok=1;
if(!ok || !ok2) return -1;
}
int cnt=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++) cnt+=(ar[i][j]==0);
return cnt;
}
/*void _(){
int nn; cin >> nn;
vector<vector<int>> v(nn,vector<int>(nn));
for(int i=0;i<nn;i++){
for(int j=0;j<nn;j++){
cin >> v[i][j];
}
}
cout << biggest_stadium(nn,v) << '\n';
}
int32_t main(){
cin.tie(0); ios::sync_with_stdio(0);
int tc=1;//cin >> tc;
while(tc--) _();
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 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 |
348 KB |
partial |
7 |
Partially correct |
1 ms |
348 KB |
partial |
8 |
Partially correct |
12 ms |
3676 KB |
partial |
9 |
Partially correct |
196 ms |
54604 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 |
1 ms |
348 KB |
partial |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
0 ms |
432 KB |
partial |
11 |
Partially correct |
0 ms |
344 KB |
partial |
12 |
Partially correct |
1 ms |
344 KB |
partial |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 ms |
344 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 |
1 ms |
348 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
0 ms |
432 KB |
partial |
12 |
Partially correct |
0 ms |
344 KB |
partial |
13 |
Partially correct |
1 ms |
344 KB |
partial |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
0 ms |
352 KB |
partial |
16 |
Partially correct |
1 ms |
420 KB |
partial |
17 |
Partially correct |
0 ms |
604 KB |
partial |
18 |
Partially correct |
1 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
344 KB |
partial |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
432 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 |
Incorrect |
0 ms |
348 KB |
wrong |
26 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 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 |
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 |
1 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
432 KB |
partial |
14 |
Partially correct |
0 ms |
344 KB |
partial |
15 |
Partially correct |
1 ms |
344 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
352 KB |
partial |
18 |
Partially correct |
1 ms |
420 KB |
partial |
19 |
Partially correct |
0 ms |
604 KB |
partial |
20 |
Partially correct |
1 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
344 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
432 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 |
Incorrect |
0 ms |
348 KB |
wrong |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 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 |
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 |
1 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
432 KB |
partial |
14 |
Partially correct |
0 ms |
344 KB |
partial |
15 |
Partially correct |
1 ms |
344 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
352 KB |
partial |
18 |
Partially correct |
1 ms |
420 KB |
partial |
19 |
Partially correct |
0 ms |
604 KB |
partial |
20 |
Partially correct |
1 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
344 KB |
partial |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
432 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 |
Incorrect |
0 ms |
348 KB |
wrong |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
1 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 |
348 KB |
partial |
8 |
Partially correct |
1 ms |
348 KB |
partial |
9 |
Partially correct |
12 ms |
3676 KB |
partial |
10 |
Partially correct |
196 ms |
54604 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 |
1 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Partially correct |
0 ms |
432 KB |
partial |
19 |
Partially correct |
0 ms |
344 KB |
partial |
20 |
Partially correct |
1 ms |
344 KB |
partial |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
352 KB |
partial |
23 |
Partially correct |
1 ms |
420 KB |
partial |
24 |
Partially correct |
0 ms |
604 KB |
partial |
25 |
Partially correct |
1 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
344 KB |
partial |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
432 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 |
Incorrect |
0 ms |
348 KB |
wrong |
33 |
Halted |
0 ms |
0 KB |
- |