제출 #840863

#제출 시각아이디문제언어결과실행 시간메모리
8408637mody축구 경기장 (IOI23_soccer)C++17
0 / 100
1 ms340 KiB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<int>> row;
vector<vector<int>> col;
vector<vector<int>> arr;
int n;

bool check(int x1,int y1,int x2,int y2){
    // int minx=min(x1,x2),maxx=max(x1,x2);
    // int mixy=min(y1,y2),maxy=max(y1,y2);
    return ((row[x1][y1] - row[x2][y1] == 0 && col[x2][y1] - col[x2][y2] == 0) || (col[x1][y1] - col[x1][y2] == 0 && row[x1][y2] - row[x2][y2] == 0));
}

int biggest_stadium(int N, vector<vector<int>> F)
{
    arr=F;
    n=N;
    int ans=0;
    row=F;
    col=F;
    for(int i=0; i < n;i++){
        for(int j=1; j < n;j++){
            row[i][j]+=row[i][j-1];
            col[j][i]+=col[j-1][i];
        }
    }
    
    queue<pair<int,int>> q;

    for(int i=0; i < n;i++){
        for(int j=0; j < n;j++){
            int curr=1;
            if(!arr[i][j]){
                q.push({i+1,j});
                q.push({i,j+1});
                q.push({i-1,j});
                q.push({i,j-1});
            }
            vector<pair<int,int>> found;
            vector<vector<bool>> vis(n,vector<bool>(n));
            found.push_back({i,j});
            while(!q.empty()){
                int x=q.front().first,y=q.front().second;
                q.pop();
                bool ok=true;
                if(x==0 || x==n || y==0 || y==n || arr[x][y] || vis[x][y]) continue;
                for(pair<int,int> c : found){
                    if(!check(c.first,c.second, x , y)){
                        ok=false;
                        break;
                    }
                }
                if(!ok) continue;
                vis[x][y]=true;
                curr++;
                q.push({x+1,y});
                q.push({x,y+1});
                q.push({x-1,y});
                q.push({x,y-1});
            }
            ans=max(ans,curr);
        }
    }
    return ans;
}
#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...