This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 check_size(vector<int> Size){
int Last = -1;
int flag = 0;
int answer = 1;
for(int i:Size){
if(!flag && i<Last) flag = 1;
if(flag && i>Last) answer = 0;
}
return answer;
}
int cover(vector<pair<int,pair<int,int>>> S){
int answer = 1;
int Last_L = S[0].second.first,Last_R = S[0].second.second;
for(auto i:S){
if(i.second.first>Last_L || i.second.second<Last_R) answer = 0;
Last_L = i.second.first;
Last_R = i.second.second;
}
return answer;
}
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(a[i]>=0 && b[i]>=0 && ( b[i]<a[i+1] || b[i+1]<a[i])) return 0;
}
if(!check_Left(a) || !check_Right(b)) return 0;
vector<int> Size;
for(int i=0;i<N;i++){
if(a[i]>=0 && b[i]>=0){
Size.push_back(b[i]-a[i]);
}
}
if(!check_size(Size)) return 0;
vector<pair<int,pair<int,int>>> final_check;
for(int i=0;i<N;i++){
if(a[i]>=0 && b[i]>=0){
final_check.push_back(make_pair(b[i]-a[i],make_pair(a[i],b[i])));
}
}
sort(final_check.begin(),final_check.end());
if(!cover(final_check)) return 0;
return Count;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |