답안 #842667

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842667 2023-09-03T08:15:08 Z nonono 축구 경기장 (IOI23_soccer) C++17
44.5 / 100
704 ms 506176 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;

const int mxN = 505;

void upMax(int &x, int y) {
    x = max(x, y);
}

int sub1(int N, vector<vector<int>> F) {
    for(int i = 0; i < N; i ++) {
        for(int j = 0; j < N; j ++) {
            if(F[i][j] == 1) {
                return max({
                    N * i + N * j - i * j,
                    N * i + N * (N - j - 1) - i * (N - j - 1),
                    N * (N - i - 1) + N * j - (N - i - 1) * j,
                    N * (N - i - 1) + N * (N - j - 1) - (N - i - 1) * (N - j - 1)
                });
            }
        }
    }

    return N * N;
}

int sub5(int N, vector<vector<int>> F) {
    vector<vector<int>> sum(N, vector<int> (N, 0)), high(N, vector<int> (N, 0));
    vector<vector<vector<int>>> low(N, vector<vector<int>> (N, vector<int> (N, 0)));

    for(int i = 0; i < N; i ++) {
        partial_sum(F[i].begin(), F[i].end(), sum[i].begin());
    }

    auto get_sum = [&] (int row, int l, int r) {
        return sum[row][r] - (!l ? 0 : sum[row][l - 1]);
    };

    for(int i = 0; i < N; i ++) {
        for(int j = 0; j < N; j ++) {
            high[i][j] = (F[i][j] ? 0 : (i ? high[i - 1][j] : 0) + 1);
        }
    }

    for(int i = 0; i < N; i ++) {
        for(int k = 0; k < N; k ++) {
            int x = high[i][k];

            for(int j = k; j >= 0; j --) {
                x = min(x, high[i][j]);
                low[i][j][k] = x;
            }
        }
    }

    vector<vector<int>> dp(N, vector<int> (N, 0));
    int result = 0;

    for(int row = 0; row < N; row ++) {
        for(int i = 0; i < N; i ++) {
            for(int j = i; j + 1 < N; j ++) {
                if(get_sum(row, i, j)) dp[i][j] = 0;
            }
        }

        for(int i = 0, j = 0; i < N; i = j + 1) {
            for(j = i; j + 1 < N && F[row][j + 1] == F[row][i]; ) j ++ ;
            if(F[row][i]) continue ;

            for(int k = (j - i + 1); k > 0; k --) {
                for(int l = i; l + k - 1 <= j; l ++) {
                    int r = l + k - 1;

                    if(k > 1) {
                        if(l + 1 < N) upMax(dp[l + 1][r], dp[l][r] + low[row][l][r]);
                        if(r - 1 >= 0) upMax(dp[l][r - 1], dp[l][r] + low[row][l][r]);
                    } else {
                        upMax(result, dp[l][r] + low[row][l][r]);
                    }
                }
            }
        }
    }

    return result;
}

int biggest_stadium(int N, vector<vector<int>> F) {
    if(N <= 500) return sub5(N, F);
    return sub1(N, F);
}

/*int main() {
    int N;
    cin >> N;

    vector<vector<int>> F(N, vector<int> (N));

    for(int i = 0; i < N; i ++) {
        for(int j = 0; j < N; j ++) {
            cin >> F[i][j];
        }
    }

    cout << biggest_stadium(N, F) << "\n";
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 344 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 1 ms 428 KB ok
6 Correct 1 ms 344 KB ok
7 Correct 5 ms 4956 KB ok
8 Correct 704 ms 505680 KB ok
9 Correct 286 ms 49488 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 0 ms 344 KB ok
8 Correct 0 ms 348 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 512 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 0 ms 344 KB ok
8 Correct 0 ms 344 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 ms 512 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 344 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 0 ms 344 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 0 ms 344 KB ok
20 Correct 0 ms 344 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 1 ms 344 KB ok
24 Correct 0 ms 344 KB ok
25 Correct 0 ms 344 KB ok
26 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 512 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 0 ms 344 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 ms 344 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 344 KB ok
24 Correct 0 ms 344 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 0 ms 344 KB ok
27 Correct 0 ms 344 KB ok
28 Correct 0 ms 344 KB ok
29 Correct 1 ms 344 KB ok
30 Partially correct 0 ms 348 KB partial
31 Partially correct 1 ms 344 KB partial
32 Correct 0 ms 344 KB ok
33 Correct 1 ms 344 KB ok
34 Correct 0 ms 344 KB ok
35 Correct 1 ms 344 KB ok
36 Correct 1 ms 344 KB ok
37 Correct 1 ms 344 KB ok
38 Correct 1 ms 348 KB ok
39 Correct 1 ms 344 KB ok
40 Correct 1 ms 344 KB ok
41 Correct 1 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 344 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 348 KB ok
9 Correct 0 ms 344 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 344 KB ok
13 Correct 0 ms 512 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 0 ms 344 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 ms 344 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 344 KB ok
24 Correct 0 ms 344 KB ok
25 Correct 1 ms 344 KB ok
26 Correct 0 ms 344 KB ok
27 Correct 0 ms 344 KB ok
28 Correct 0 ms 344 KB ok
29 Correct 1 ms 344 KB ok
30 Partially correct 0 ms 348 KB partial
31 Partially correct 1 ms 344 KB partial
32 Correct 0 ms 344 KB ok
33 Correct 1 ms 344 KB ok
34 Correct 0 ms 344 KB ok
35 Correct 1 ms 344 KB ok
36 Correct 1 ms 344 KB ok
37 Correct 1 ms 344 KB ok
38 Correct 1 ms 348 KB ok
39 Correct 1 ms 344 KB ok
40 Correct 1 ms 344 KB ok
41 Correct 1 ms 344 KB ok
42 Correct 396 ms 505720 KB ok
43 Correct 396 ms 505936 KB ok
44 Partially correct 531 ms 505920 KB partial
45 Partially correct 586 ms 505680 KB partial
46 Correct 415 ms 506176 KB ok
47 Correct 667 ms 505684 KB ok
48 Correct 479 ms 505920 KB ok
49 Correct 490 ms 505720 KB ok
50 Correct 537 ms 506028 KB ok
51 Correct 451 ms 505928 KB ok
52 Correct 381 ms 505928 KB ok
53 Correct 359 ms 505920 KB ok
54 Correct 388 ms 505852 KB ok
55 Correct 407 ms 505804 KB ok
56 Correct 471 ms 505936 KB ok
57 Correct 585 ms 505936 KB ok
58 Correct 619 ms 505924 KB ok
59 Correct 587 ms 506112 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 0 ms 344 KB ok
4 Correct 1 ms 344 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 1 ms 428 KB ok
7 Correct 1 ms 344 KB ok
8 Correct 5 ms 4956 KB ok
9 Correct 704 ms 505680 KB ok
10 Correct 286 ms 49488 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 0 ms 344 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 ms 512 KB ok
19 Correct 0 ms 344 KB ok
20 Correct 0 ms 344 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 344 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 344 KB ok
27 Correct 0 ms 344 KB ok
28 Correct 0 ms 344 KB ok
29 Correct 0 ms 344 KB ok
30 Correct 1 ms 344 KB ok
31 Correct 0 ms 344 KB ok
32 Correct 0 ms 344 KB ok
33 Correct 0 ms 344 KB ok
34 Correct 1 ms 344 KB ok
35 Partially correct 0 ms 348 KB partial
36 Partially correct 1 ms 344 KB partial
37 Correct 0 ms 344 KB ok
38 Correct 1 ms 344 KB ok
39 Correct 0 ms 344 KB ok
40 Correct 1 ms 344 KB ok
41 Correct 1 ms 344 KB ok
42 Correct 1 ms 344 KB ok
43 Correct 1 ms 348 KB ok
44 Correct 1 ms 344 KB ok
45 Correct 1 ms 344 KB ok
46 Correct 1 ms 344 KB ok
47 Correct 396 ms 505720 KB ok
48 Correct 396 ms 505936 KB ok
49 Partially correct 531 ms 505920 KB partial
50 Partially correct 586 ms 505680 KB partial
51 Correct 415 ms 506176 KB ok
52 Correct 667 ms 505684 KB ok
53 Correct 479 ms 505920 KB ok
54 Correct 490 ms 505720 KB ok
55 Correct 537 ms 506028 KB ok
56 Correct 451 ms 505928 KB ok
57 Correct 381 ms 505928 KB ok
58 Correct 359 ms 505920 KB ok
59 Correct 388 ms 505852 KB ok
60 Correct 407 ms 505804 KB ok
61 Correct 471 ms 505936 KB ok
62 Correct 585 ms 505936 KB ok
63 Correct 619 ms 505924 KB ok
64 Correct 587 ms 506112 KB ok
65 Partially correct 239 ms 49432 KB partial
66 Partially correct 249 ms 49492 KB partial
67 Partially correct 247 ms 49432 KB partial
68 Partially correct 249 ms 49436 KB partial
69 Partially correct 237 ms 49416 KB partial
70 Partially correct 245 ms 49436 KB partial
71 Partially correct 244 ms 49432 KB partial
72 Partially correct 240 ms 49540 KB partial
73 Incorrect 252 ms 49540 KB wrong
74 Halted 0 ms 0 KB -