#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int size(pair<int,int> a) { return a.second - a.first + 1; }
bool checkIntervals(pair<int,int> a, pair<int,int> b) { return (b.first <= a.first && a.second <= b.second); }
bool isGood(int N, vector<vector<int>>& F)
{
vector<pair<int,int>> intervals;
for(int i = 0 ; i < N ; i++)
{
int numCells = 0;
int minCell = N, maxCell = -1;
for(int j = 0 ; j < N ; j++)
{
if( F[i][j] == 0 )
{
numCells++;
minCell = min( minCell , j );
maxCell = max( maxCell , j );
}
}
if( numCells == 0 )
continue;
if( numCells != maxCell - minCell + 1 )
return false;
intervals.push_back( { minCell , maxCell } );
}
int p = 0;
while( p + 1 < (int)intervals.size() && size(intervals[p]) <= size(intervals[p + 1]) )
{
if( !checkIntervals( intervals[p] , intervals[p + 1] ) )
return false;
p++;
}
while( p + 1 < (int)intervals.size() && size(intervals[p]) >= size(intervals[p + 1]) )
{
if( !checkIntervals( intervals[p + 1] , intervals[p] ) )
return false;
p++;
}
if( p != (int)intervals.size() - 1 )
return false;
sort( intervals.begin() , intervals.end() , [&](pair<int,int> a, pair<int,int> b){
return size(a) < size(b);
});
for(int i = 0 ; i + 1 < (int)intervals.size() ; i++)
if( !checkIntervals( intervals[i] , intervals[i + 1] ) ) return false;
return true;
}
int biggest_stadium(int N, vector<vector<int>> F)
{
if( !isGood(N, F) )
return -1;
int sum = 0;
for(int i = 0 ; i < N ; i++)
for(int j = 0 ; j < N ; j++)
sum += 1 - F[i][j];
return sum;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
344 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
1 ms |
348 KB |
partial |
8 |
Partially correct |
16 ms |
2200 KB |
partial |
9 |
Partially correct |
232 ms |
31828 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Partially correct |
0 ms |
344 KB |
partial |
4 |
Partially correct |
0 ms |
348 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Partially correct |
0 ms |
344 KB |
partial |
11 |
Incorrect |
0 ms |
348 KB |
wrong |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Partially correct |
0 ms |
344 KB |
partial |
5 |
Partially correct |
0 ms |
348 KB |
partial |
6 |
Partially correct |
0 ms |
348 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Partially correct |
0 ms |
344 KB |
partial |
12 |
Incorrect |
0 ms |
348 KB |
wrong |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 KB |
partial |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
344 KB |
partial |
14 |
Incorrect |
0 ms |
348 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Partially correct |
0 ms |
344 KB |
partial |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
0 ms |
348 KB |
partial |
9 |
Partially correct |
0 ms |
348 KB |
partial |
10 |
Partially correct |
0 ms |
348 KB |
partial |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Partially correct |
0 ms |
344 KB |
partial |
14 |
Incorrect |
0 ms |
348 KB |
wrong |
15 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
344 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
344 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Partially correct |
0 ms |
348 KB |
partial |
8 |
Partially correct |
1 ms |
348 KB |
partial |
9 |
Partially correct |
16 ms |
2200 KB |
partial |
10 |
Partially correct |
232 ms |
31828 KB |
partial |
11 |
Partially correct |
0 ms |
344 KB |
partial |
12 |
Partially correct |
0 ms |
348 KB |
partial |
13 |
Partially correct |
0 ms |
348 KB |
partial |
14 |
Partially correct |
0 ms |
348 KB |
partial |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Partially correct |
0 ms |
344 KB |
partial |
19 |
Incorrect |
0 ms |
348 KB |
wrong |
20 |
Halted |
0 ms |
0 KB |
- |