#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fs first
#define sc second
const int mxn = 2022;
int N;
pii rng[mxn];
vector<pii> solve(vector<int> &row){
vector<pii> v;
for(int i = 0;i<N;i++){
if(!row[i]){
if(v.empty()||v.back().sc+1 != i)v.push_back(pii(i,i));
else v.back().sc++;
}
}
return v;
}
bool check(vector<vector<int>> &F){
for(int i = 0;i<N;i++)rng[i] = pii(-1,-1);
for(int i = 0;i<N;i++){
vector<pii> v;
v = solve(F[i]);
if(v.size()>1)return 0;
if(v.size()==1)rng[i] = v[0];
else rng[i] = pii(N,N);
}
int mx = max_element(rng,rng+N)-rng;
for(int i = mx-1;i>=0;i--){
pii pre = rng[i+1],now = rng[i];
if(pre.fs == N&&now.fs != N)return false;
if(pre.fs>now.fs||pre.sc<now.sc)return false;
}
for(int i = mx+1;i<N;i++){
pii pre = rng[i-1],now = rng[i];
if(pre.fs == N&&now.fs != N)return false;
if(pre.fs>now.fs||pre.sc<now.sc)return false;
}
return true;
}
int biggest_stadium(int NN, std::vector<std::vector<int>> F){
N = NN;
int cnt = 0;
for(int i = 0;i<N;i++){
for(int j = 0;j<N;j++)F[i][j],cnt += F[i][j];
}
if(!check(F))return false;
for(int i = 0;i<N;i++){
for(int j = 0;j<i;j++)swap(F[i][j],F[j][i]);
}
if(!check(F))return false;
return cnt;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Incorrect |
0 ms |
344 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Incorrect |
0 ms |
344 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Incorrect |
0 ms |
344 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Incorrect |
0 ms |
344 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |