답안 #1041953

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1041953 2024-08-02T10:49:29 Z ZanP 축구 경기장 (IOI23_soccer) C++17
0 / 100
4500 ms 70920 KB
#include "soccer.h"
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int biggest_stadium(int n, vector<vector<int>> grid) {
    vector<vector<int>> dist_up(n, vector<int>(n, 0)), dist_down(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
        dist_up[0][i] = 1 - grid[0][i];
        dist_down[n - 1][i] = 1 - grid[n - 1][i];
    }

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            dist_up[i][j] = grid[i][j] ? 0 : 1 + dist_up[i - 1][j];
            dist_down[n - i - 1][j] = grid[n - i - 1][j] ? 0 : 1 + dist_down[n - i][j];
        }
    }

    int ans = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (grid[i][j]) { continue; }
            int dist = dist_up[i][j];
            int sub_ans = dist;
            for (int x = j - 1; dist && x >= 0; x--) {
                dist = min(dist_up[i][x], dist);
                sub_ans += dist;
            }
            for (int x = j + 1; dist && x < n; x++) {
                dist = min(dist_up[i][x], dist);
                sub_ans += dist;
            }
            dist = dist_down[i][j] - 1;
            sub_ans += dist;
            for (int x = j - 1; dist && x >= 0; x--) {
                dist = min(dist_down[i][x] - 1, dist);
                if (dist < 0) { break; }
                sub_ans += dist;
            }
            for (int x = j + 1; dist && x < n; x++) {
                dist = min(dist_down[i][x] - 1, dist);
                if (dist < 0) { break; }
                sub_ans += dist;
            }

            ans = max(ans, sub_ans);
        }
    }

    return ans;
}

// int main() {
//     cout << biggest_stadium(5, { {0, 0, 0, 0, 0},
//  {1, 0, 0, 0, 0},
//  {0, 0, 0, 0, 0},
//  {0, 0, 0, 0, 0},
//  {0, 0, 1, 0, 0} }) << '\n';

// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 3 ms 604 KB ok
8 Correct 241 ms 4876 KB ok
9 Execution timed out 4552 ms 70920 KB Time limit exceeded
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 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 Correct 0 ms 348 KB ok
8 Correct 0 ms 436 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 436 KB ok
12 Correct 0 ms 344 KB ok
13 Incorrect 0 ms 348 KB wrong
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 344 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 436 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 436 KB ok
13 Correct 0 ms 344 KB ok
14 Incorrect 0 ms 348 KB wrong
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 344 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 436 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 436 KB ok
15 Correct 0 ms 344 KB ok
16 Incorrect 0 ms 348 KB wrong
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 344 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 436 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 436 KB ok
15 Correct 0 ms 344 KB ok
16 Incorrect 0 ms 348 KB wrong
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 3 ms 604 KB ok
9 Correct 241 ms 4876 KB ok
10 Execution timed out 4552 ms 70920 KB Time limit exceeded
11 Halted 0 ms 0 KB -