#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,-1);
}
pii now = pii(N,N);int mx = -1;
for(int i = 0;i<N;i++){
if(now.fs > rng[i].fs){
mx = i;
now = rng[i];
}
else if(now.fs == rng[i].fs&&now.sc<=rng[i].sc){
mx = i;
now = rng[i];
}
}
for(int i = 0;i<N;i++)cerr<<rng[i].fs<<','<<rng[i].sc<<endl;
cerr<<"MX = "<<mx<<endl;
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(F[0][0] == 1||F[N-1][N-1] == 1||F[0][N-1] == 1||F[N-1][0] == 1)return cnt;
return 0;
if(!check(F))return false;
cerr<<"ROW PASS!"<<endl;
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;
cerr<<"COL PASS!"<<endl;
return cnt;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
760 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Incorrect |
0 ms |
348 KB |
wrong |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Incorrect |
0 ms |
348 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Incorrect |
0 ms |
348 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
760 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Incorrect |
0 ms |
348 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
760 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Incorrect |
0 ms |
348 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
1 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
344 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
760 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Incorrect |
0 ms |
348 KB |
wrong |
7 |
Halted |
0 ms |
0 KB |
- |