답안 #1076779

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076779 2024-08-26T16:26:23 Z mickey080929 축구 경기장 (IOI23_soccer) C++17
1.5 / 100
269 ms 55376 KB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};

int biggest_stadium(int N, vector<vector<int>> F) {
    vector<vector<int>> vis(N, vector<int>(N, 0));
    queue<pair<int,int>> q;
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            if (F[i][j] == 0) {
                vis[i][j] = 1;
                q.push({i, j});
                break;
            }
        }
        if (!q.empty()) break;
    }
    while (!q.empty()) {
        int x = q.front().first;
        int y = q.front().second;
        q.pop();
        for (int k=0; k<4; k++) {
            int nx = x + dx[k];
            int ny = y + dy[k];
            if (nx < 0 || nx >= N || ny < 0 || ny >= N) continue;
            if (vis[nx][ny]) continue;
            vis[nx][ny] = 1;
            q.push({nx, ny});
        }
    }
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            if (F[i][j] == 0 && vis[i][j] == 0) {
                return 0;
            }
        }
    }
    int tot = 0;
    bool flag = false;
    int pl = -1, pr = -1;
    for (int i=0; i<N; i++) {
        int l = -1, r = -1, cnt = 0;
        for (int j=0; j<N; j++) {
            if (F[i][j] == 0) {
                if (l == -1) l = j;
                r = j;
                cnt ++;
            }
        }
        if (cnt == 0) {
            pl = -1; pr = -1;
            continue;
        }
        if (r - l + 1 != cnt) {
            return 0;
        }
        if (pl != -1) {
            if (!flag) {
                if (l <= pl && pr <= r) {}
                else if (pl <= l && r <= pr) {
                    flag = true;
                }
                else return 0;
            }
            else {
                if (pl <= l && r <= pr) {}
                else return 0;
            }
        }
        pl = l; pr = r;
        tot += cnt;
    }
    flag = false;
    pl = -1; pr = -1;
    for (int i=0; i<N; i++) {
        int l = -1, r = -1, cnt = 0;
        for (int j=0; j<N; j++) {
            if (F[j][i] == 0) {
                if (l == -1) l = j;
                r = j;
                cnt ++;
            }
        }
        if (cnt == 0) {
            pl = -1; pr = -1;
            continue;
        }
        if (r - l + 1 != cnt) {
            return 0;
        }
        if (pl != -1) {
            if (!flag) {
                if (l <= pl && pr <= r) {}
                else if (pl <= l && r <= pr) {
                    flag = true;
                }
                else return 0;
            }
            else {
                if (pl <= l && r <= pr) {}
                else return 0;
            }
        }
        pl = l; pr = r;
    }

    return tot;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB ok
2 Correct 0 ms 432 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 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 17 ms 3716 KB partial
9 Partially correct 269 ms 55376 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB ok
2 Correct 0 ms 432 KB ok
3 Partially correct 0 ms 344 KB partial
4 Partially correct 1 ms 348 KB partial
5 Partially correct 0 ms 348 KB partial
6 Partially correct 0 ms 600 KB partial
7 Incorrect 0 ms 348 KB wrong
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 432 KB ok
4 Partially correct 0 ms 344 KB partial
5 Partially correct 1 ms 348 KB partial
6 Partially correct 0 ms 348 KB partial
7 Partially correct 0 ms 600 KB partial
8 Incorrect 0 ms 348 KB wrong
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 432 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Partially correct 0 ms 344 KB partial
7 Partially correct 1 ms 348 KB partial
8 Partially correct 0 ms 348 KB partial
9 Partially correct 0 ms 600 KB partial
10 Incorrect 0 ms 348 KB wrong
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 432 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Partially correct 0 ms 344 KB partial
7 Partially correct 1 ms 348 KB partial
8 Partially correct 0 ms 348 KB partial
9 Partially correct 0 ms 600 KB partial
10 Incorrect 0 ms 348 KB wrong
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 344 KB partial
2 Correct 1 ms 604 KB ok
3 Correct 0 ms 432 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 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 17 ms 3716 KB partial
10 Partially correct 269 ms 55376 KB partial
11 Partially correct 0 ms 344 KB partial
12 Partially correct 1 ms 348 KB partial
13 Partially correct 0 ms 348 KB partial
14 Partially correct 0 ms 600 KB partial
15 Incorrect 0 ms 348 KB wrong
16 Halted 0 ms 0 KB -