#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int check_all( vector<vector<int>> &mat ){
int n = mat.size();
vector<int> l(n, n), r(n, -1);
int tot = 0;
for( int i = 0; i < n; i++ )
for( int j = 0; j < n; j++ ) if( mat[i][j] == 0 ){
tot++;
l[i] = min( l[i], j );
r[i] = max( r[i], j );
}
auto contains = [&]( int a, int b ){
return l[a] <= l[b] && r[b] <= r[a];
};
int cont = 0;
for( int i = 0; i < n; i++ ) if( l[i] != n ){
cont += (r[i] - l[i] + 1);
for( int j = i + 1; j < n; j++ ) if( l[j] != n && !contains( i, j ) && !contains( j, i ) ) return 0;
}
if( tot < cont ) return 0;
fill( l.begin(), l.end(), n );
fill( r.begin(), r.end(), -1 );
for( int i = 0; i < n; i++ )
for( int j = 0; j < n; j++ ) if( mat[j][i] == 0 ){
l[i] = min( l[i], j );
r[i] = max( r[i], j );
}
cont = 0;
for( int i = 0; i < n; i++ ) if( l[i] != n ){
cont += (r[i] - l[i] + 1);
for( int j = i + 1; j < n; j++ ) if( l[j] != n && !contains( i, j ) && !contains( j, i ) ) return 0;
}
if( tot < cont ) return 0;
return tot;
}
int biggest_stadium(int n, vector<vector<int>> mat ){
return check_all(mat);
}
# | 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... |