제출 #1327758

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

int n, tot;
vector<vector<int>> grid;
vector<vector<bool>> vis;

void flood(int i, int j) {
    if (i < 0 || i >= n || j < 0 || j >= n || vis[i][j] || grid[i][j]) return;
    tot++;
    vis[i][j] = true;
    flood(i-1, j);
    flood(i+1, j);
    flood(i, j+1);
    flood(i, j-1);
}

int biggest_stadium(int N, std::vector<std::vector<int>> F) {
    n = N;
    grid = F;
    vis.assign(n, vector<bool>(n, false));
    if (n == 1) return 1;
    tot = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            tot += grid[i][j];
        }
    }
    if (tot == 0) return n * n;
    tot = 0;
    int ans = 1;
    if (n <= 2 || (n == 3 && grid[1][1] == 0)) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (grid[i][j] || vis[i][j]) continue;
                tot = 0;
                flood(i, j);
                ans = max(ans, tot);
            }
        }
        return ans;
    }
    int curr = 0;
    if (grid[0][0] == 0) {
        curr = 1;
        for (int i = 1; i <= 2; i++) {
            if (grid[0][i]) break;
            curr++;
        }
        for (int i = 1; i <= 2; i++) {
            if (grid[i][0]) break;
            curr++;
        }
        ans = max(ans, curr);
    }
    if (grid[0][2] == 0) {
        curr = 1;
        for (int i = 1; i <= 2; i++) {
            if (grid[0][2-i]) break;
            curr++;
        }
        for (int i = 1; i <= 2; i++) {
            if (grid[i][2]) break;
            curr++;
        }
        ans = max(ans, curr);
    }
    if (grid[2][0] == 0) {
        curr = 1;
        for (int i = 1; i <= 2; i++) {
            if (grid[2][i]) break;
            curr++;
        }
        for (int i = 1; i <= 2; i++) {
            if (grid[2-i][0]) break;
            curr++;
        }
        ans = max(ans, curr);
    }
    if (grid[2][2] == 0) {
        curr = 1;
        for (int i = 1; i <= 2; i++) {
            if (grid[2][2-i]) break;
            curr++;
        }
        for (int i = 1; i <= 2; i++) {
            if (grid[2-i][2]) break;
            curr++;
        }
        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...