제출 #841330

#제출 시각아이디문제언어결과실행 시간메모리
841330Lawliet축구 경기장 (IOI23_soccer)C++17
3.50 / 100
231 ms31760 KiB
#include "soccer.h"
#include <iostream>
#include <vector>
// #include <bits/stdc++.h>
 
using namespace std;
 
bool checkIntervals(pair<int,int> a, pair<int,int> b)
{
    if( a.second - a.first + 1 > b.second - b.first + 1 )
        swap( a , 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 } );
    }
 
    return checkIntervals( intervals.front() , intervals.back() );
}
 
int biggest_stadium(int N, vector<vector<int>> F)
{
    if( !isGood(N, F) )
        return -1;
 
    for(int i = 0 ; i < N ; i++)
        for(int j = 0 ; j < i ; j++)
            swap( F[i][j] , F[j][i] );
 
    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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...