답안 #1078319

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078319 2024-08-27T15:16:10 Z PanosPask 축구 경기장 (IOI23_soccer) C++17
3.5 / 100
226 ms 70328 KB
#include "soccer.h"

using namespace std;

typedef pair<int, int> pi;

vector<vector<int>> grid;
vector<pi> row_range;

vector<vector<int>> rotated;
vector<pi> column_range;

bool check_row(vector<int>& r, vector<pi>& range, int pos)
{
    range[pos] = {-1, -1};

    for (int i = 0; i < r.size(); i++) {
        if (r[i] == 0) {
            if (range[pos].second != -1) {
                return false;
            }
            if (range[pos].first == -1) {
                range[pos].first = i;
            }
        }
        else {
            if (range[pos].first != -1) {
                range[pos].second = i;
            }
        }
    }

    if (range[pos].second == -1) {
        range[pos].second = r.size();
    }

    return true;
}

bool included(pi a, pi b)
{
    if (b.first == -1) {
        return true;
    }

    return a.first <= b.first && a.second >= b.second;
}

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    grid.resize(N, vector<int>(N));
    rotated.resize(N, vector<int>(N));
    column_range.resize(N);
    row_range.resize(N);

    int tot = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            grid[i][j] = F[i][j];
            rotated[j][i] = F[i][j];
            tot += !F[i][j];
        }
    }

    bool good = true;
    for (int i = 0; i < N; i++) {
        good = good && check_row(grid[i], row_range, i) && check_row(rotated[i], column_range, i);
    }

    if (!good) {
        return 0;
    }

    for (int j = 0; j < N; j++) {
        if (column_range[j].first == -1) {
            continue;
        }

        pi propagate_range = {-1, -1};
        for (int i = 0; i < column_range[j].second; i++) {
            if (!included(row_range[i], propagate_range)) {
                return 0;
            }

            if (row_range[i].first != -1) {
                if (F[i][j]) {
                    propagate_range = row_range[i];
                }
            }
        }

        propagate_range = {-1, -1};
        for (int i = N - 1; i >= column_range[j].first; i--) {
            if (!included(row_range[i], propagate_range)) {
                return 0;
            }

            if (row_range[i].first != -1) {
                if (F[i][j]) {
                    propagate_range = row_range[i];
                }
            }
        }
    }

    return tot;
}

Compilation message

soccer.cpp: In function 'bool check_row(std::vector<int>&, std::vector<std::pair<int, int> >&, int)':
soccer.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < r.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 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 604 KB partial
8 Partially correct 15 ms 4700 KB partial
9 Partially correct 226 ms 70328 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 348 KB ok
3 Partially correct 0 ms 348 KB partial
4 Partially correct 0 ms 348 KB partial
5 Partially correct 0 ms 344 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 348 KB partial
11 Partially correct 0 ms 348 KB partial
12 Partially correct 1 ms 348 KB partial
13 Correct 0 ms 428 KB ok
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Partially correct 0 ms 348 KB partial
5 Partially correct 0 ms 348 KB partial
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 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Partially correct 0 ms 348 KB partial
12 Partially correct 0 ms 348 KB partial
13 Partially correct 1 ms 348 KB partial
14 Correct 0 ms 428 KB ok
15 Partially correct 0 ms 348 KB partial
16 Partially correct 1 ms 344 KB partial
17 Partially correct 0 ms 348 KB partial
18 Partially correct 0 ms 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Correct 0 ms 348 KB ok
21 Incorrect 0 ms 344 KB wrong
22 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 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 0 ms 348 KB partial
8 Partially correct 0 ms 344 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 348 KB partial
14 Partially correct 0 ms 348 KB partial
15 Partially correct 1 ms 348 KB partial
16 Correct 0 ms 428 KB ok
17 Partially correct 0 ms 348 KB partial
18 Partially correct 1 ms 344 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Partially correct 0 ms 348 KB partial
22 Correct 0 ms 348 KB ok
23 Incorrect 0 ms 344 KB wrong
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 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 0 ms 348 KB partial
8 Partially correct 0 ms 344 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 348 KB partial
14 Partially correct 0 ms 348 KB partial
15 Partially correct 1 ms 348 KB partial
16 Correct 0 ms 428 KB ok
17 Partially correct 0 ms 348 KB partial
18 Partially correct 1 ms 344 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 0 ms 348 KB partial
21 Partially correct 0 ms 348 KB partial
22 Correct 0 ms 348 KB ok
23 Incorrect 0 ms 344 KB wrong
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Partially correct 0 ms 348 KB partial
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 344 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 604 KB partial
9 Partially correct 15 ms 4700 KB partial
10 Partially correct 226 ms 70328 KB partial
11 Partially correct 0 ms 348 KB partial
12 Partially correct 0 ms 348 KB partial
13 Partially correct 0 ms 344 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 348 KB partial
19 Partially correct 0 ms 348 KB partial
20 Partially correct 1 ms 348 KB partial
21 Correct 0 ms 428 KB ok
22 Partially correct 0 ms 348 KB partial
23 Partially correct 1 ms 344 KB partial
24 Partially correct 0 ms 348 KB partial
25 Partially correct 0 ms 348 KB partial
26 Partially correct 0 ms 348 KB partial
27 Correct 0 ms 348 KB ok
28 Incorrect 0 ms 344 KB wrong
29 Halted 0 ms 0 KB -