#include<bits/stdc++.h>
#include "soccer.h"
using namespace std;
pair<int,int> process(vector<int> S){
int L=-1,R=-1,flag = 1;
for(int i=0;i<(int)S.size();i++){
if(!S[i] && L==-1){
L = i; R = i;
}
else if(!S[i] && R==i-1){
R=i;
}
else if(!S[i]){
flag = 0;
}
}
if(!flag) return make_pair(-2,-2);
return make_pair(L,R);
}
int check_Left(vector<int> List){
int answer=1,down=0,flag = 0, Last = -1 , next_level = 0;
for(int i:List){
if(i==-2) answer=0;
else if(i==-1 && Last!=-1) flag = 1;
else{
if(flag) answer = 0;
if(Last==-1) Last = i;
else{
if(i>Last && next_level==0) next_level = 1;
else if(i<Last && next_level==1) answer = 0;
}
Last = i;
}
}
if(down > 1 || answer==0) return 0;
else return 1;
}
int check_Right(vector<int> List){
int answer=1,down=0,flag = 0, Last = -1 , next_level = 0;
for(int i:List){
if(i==-2) answer=0;
else if(i==-1 && Last!=-1) flag = 1;
else{
if(flag) answer = 0;
if(Last==-1) Last = i;
else{
if(i<Last && next_level==0) next_level = 1;
else if(i>Last && next_level==1) answer = 0;
}
Last = i;
}
}
if(down > 1 || answer==0) return 0;
else return 1;
}
int biggest_stadium(int N,vector<vector<int>> F){
vector<int> a;
vector<int> b;
int Count = 0;
for(auto i:F){
for(int j:i){
if(j==0) Count++;
}
pair<int,int> tmp = process(i);
a.push_back(tmp.first);
b.push_back(tmp.second);
}
for(int i=0;i<N-1;i++){
if(b[i]<a[i+1] || a[i]<b[i+1]) return 0;
}
if(check_Left(a) && check_Right(b)) return Count;
else return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 KB |
wrong |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
600 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 |
600 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 |
600 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 |
600 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 |
600 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |