#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>> lignes;
int biggest_stadium(int n,vector<vector<int>> grille){
int nbarbres=0;
int premier=-1,dernier=-1;
for (int i=0;i<n;i++){
int gauche=-1,droite=-1;
for (int j=0;j<n;j++){
if (grille[i][j]==1){
if (gauche!=-1 and droite==-1){
droite=j-1;
}
nbarbres++;
}
else {
if (droite!=-1){
return 0;
}
if (gauche==-1){
gauche=j;
}
}
}
if (gauche!=-1){
if (premier==-1){
premier=i;
}
dernier=i;
if (droite==-1){
droite=n-1;
}
}
lignes.push_back({gauche,droite});
}
if (lignes[premier].first<lignes[dernier].first and lignes[premier].second<lignes[dernier].second){
return 0;
}
if (lignes[premier].first>lignes[dernier].first and lignes[premier].second>lignes[dernier].second){
return 0;
}
/*for (int i=0;i<n;i++){
cout<<lignes[i].first<<" "<<lignes[i].second<<endl;
}*/
int changement=0;
for (int i=premier;i<dernier;i++){
if (lignes[i].first<lignes[i+1].first and lignes[i].second<lignes[i+1].second){
return 0;
}
if (lignes[i].first>lignes[i+1].first and lignes[i].second>lignes[i+1].second){
return 0;
}
if (lignes[i].first!=lignes[i+1].first or lignes[i].second!=lignes[i+1].second){
if (lignes[i].first>=lignes[i+1].first and lignes[i].second<=lignes[i+1].second){
if (changement==1){
return 0;
}
}
else {
changement=1;
}
}
}
return n*n-nbarbres;
}
# | 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... |