답안 #1024071

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1024071 2024-07-15T10:59:58 Z thinknoexit 축구 경기장 (IOI23_soccer) C++17
77.5 / 100
409 ms 71512 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2020;
int n;
int f[N][N], qs[N][N];
int l[N], r[N];
// check if all empty cell are regular stadium
bool all_can() {
    for (int i = 1;i <= n;i++) {
        for (int j = 1;j <= n + 1;j++) {
            if (f[i][j - 1] != f[i][j]) {
                if (!l[i]) l[i] = j;
                else if (!r[i]) r[i] = j - 1;
                else return 0;
            }
        }
    }
    for (int j = 1;j <= n;j++) {
        int cnt = 0;
        for (int i = 1;i <= n;i++) {
            cnt += f[i - 1][j] != f[i][j];
        }
        if (cnt > 2) return 0;
    }
    for (int i = 1;i <= n;i++) {
        if (l[i] == 0) continue;
        for (int j = 1;j <= n;j++) {
            if (l[j] == 0) continue;
            bool ch = (l[i] <= l[j] && r[j] <= r[i]) || (l[j] <= l[i] && r[i] <= r[j]);
            if (!ch) return 0;
        }
    }
    return 1;
}
int mx;
int l1[505][505], r1[505][505];
int L1[505], R1[505];
int dp[505][505], L[505][505], R[505][505];
int inter(int l1, int r1, int l2, int r2) {
    if (l1 > l2) {
        swap(l1, l2);
        swap(r1, r2);
    }
    // l1 <= l2
    if (r2 <= r1) return r2 - l2 + 1;
    if (r1 < l2) return 0;
    return r1 - l2 + 1;
}
int biggest_stadium(int NN, vector<vector<int>> F) {
    n = NN;
    int empty_cell = 0;
    for (int i = 1;i <= n;i++) {
        f[0][i] = f[n + 1][i] = f[i][0] = f[i][n + 1] = 1;
        for (int j = 1;j <= n;j++) {
            f[i][j] = F[i - 1][j - 1];
            qs[i][j] = qs[i][j - 1] + f[i][j];
            empty_cell += f[i][j] == 0;
        }
    }
    if (all_can()) return empty_cell;
    if (empty_cell == n * n - 1) {
        int mx = 0;
        for (int i = 1;i <= n && !mx;i++) {
            for (int j = 1;j <= n && !mx;j++) {
                if (f[i][j]) {
                    mx = max(mx, (i - 1) * n + (j - 1) * n - (i - 1) * (j - 1));
                    mx = max(mx, (n - i) * n + (j - 1) * n - (n - i) * (j - 1));
                    mx = max(mx, (i - 1) * n + (n - j) * n - (i - 1) * (n - j));
                    mx = max(mx, (n - i) * n + (n - j) * n - (n - i) * (n - j));
                }
            }
        }
        return mx;
    }
    if (n > 500) return 0;
    for (int i = 1;i <= n;i++) {
        for (int j = 0;j <= n;j++) {
            if (f[i][j] == 1) l1[i][j] = j + 1;
            else l1[i][j] = l1[i][j - 1];
        }
        for (int j = n + 1;j >= 1;j--) {
            if (f[i][j] == 1) r1[i][j] = j - 1;
            else r1[i][j] = r1[i][j + 1];
        }
    }
    mx = 0;
    for (int c = 1;c <= n;c++) {
        for (int i = 1;i <= n;i++) {
            if (f[i][c]) dp[i][i] = -1e9, L[i][i] = L1[i] = -1, R[i][i] = R1[i] = -2;
            else {
                L1[i] = l1[i][c], R1[i] = r1[i][c];
                dp[i][i] = R1[i] - L1[i] + 1, L[i][i] = L1[i], R[i][i] = R1[i];
                mx = max(mx, dp[i][i]);
            }
        }
        for (int k = 1;k < n;k++) {
            for (int i = 1;i <= n - k;i++) {
                int j = i + k;
                L[i][j] = max(L[i + 1][j], L1[i]), R[i][j] = min(R[i + 1][j], R1[i]);
                dp[i][j] = -1e9;
                if (inter(L[i + 1][j], R[i + 1][j], L1[i], R1[i]) != 0) {
                    dp[i][j] = max(dp[i][j], dp[i + 1][j] + inter(L[i + 1][j], R[i + 1][j], L1[i], R1[i]));
                }
                if (inter(L[i][j - 1], R[i][j - 1], L1[j], R1[j]) != 0) {
                    dp[i][j] = max(dp[i][j], dp[i][j - 1] + inter(L[i][j - 1], R[i][j - 1], L1[j], R1[j]));
                }
                mx = max(mx, dp[i][j]);
            }
        }
    }
    return mx;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 0 ms 2396 KB ok
4 Correct 0 ms 2396 KB ok
5 Correct 1 ms 2392 KB ok
6 Correct 1 ms 2392 KB ok
7 Correct 1 ms 2908 KB ok
8 Correct 14 ms 11352 KB ok
9 Correct 205 ms 71436 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 2396 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 1 ms 6488 KB ok
4 Correct 1 ms 6492 KB ok
5 Correct 1 ms 6488 KB ok
6 Correct 1 ms 6488 KB ok
7 Correct 1 ms 6492 KB ok
8 Correct 0 ms 2396 KB ok
9 Correct 0 ms 2392 KB ok
10 Correct 1 ms 6492 KB ok
11 Correct 1 ms 6628 KB ok
12 Correct 1 ms 6492 KB ok
13 Correct 0 ms 2396 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 0 ms 2396 KB ok
4 Correct 1 ms 6488 KB ok
5 Correct 1 ms 6492 KB ok
6 Correct 1 ms 6488 KB ok
7 Correct 1 ms 6488 KB ok
8 Correct 1 ms 6492 KB ok
9 Correct 0 ms 2396 KB ok
10 Correct 0 ms 2392 KB ok
11 Correct 1 ms 6492 KB ok
12 Correct 1 ms 6628 KB ok
13 Correct 1 ms 6492 KB ok
14 Correct 0 ms 2396 KB ok
15 Correct 1 ms 6492 KB ok
16 Correct 1 ms 6492 KB ok
17 Correct 1 ms 6492 KB ok
18 Correct 1 ms 6488 KB ok
19 Correct 1 ms 6492 KB ok
20 Correct 1 ms 2396 KB ok
21 Correct 0 ms 2492 KB ok
22 Correct 1 ms 6492 KB ok
23 Correct 1 ms 6492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6492 KB ok
26 Correct 1 ms 6492 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 0 ms 2396 KB ok
4 Correct 0 ms 2396 KB ok
5 Correct 0 ms 2396 KB ok
6 Correct 1 ms 6488 KB ok
7 Correct 1 ms 6492 KB ok
8 Correct 1 ms 6488 KB ok
9 Correct 1 ms 6488 KB ok
10 Correct 1 ms 6492 KB ok
11 Correct 0 ms 2396 KB ok
12 Correct 0 ms 2392 KB ok
13 Correct 1 ms 6492 KB ok
14 Correct 1 ms 6628 KB ok
15 Correct 1 ms 6492 KB ok
16 Correct 0 ms 2396 KB ok
17 Correct 1 ms 6492 KB ok
18 Correct 1 ms 6492 KB ok
19 Correct 1 ms 6492 KB ok
20 Correct 1 ms 6488 KB ok
21 Correct 1 ms 6492 KB ok
22 Correct 1 ms 2396 KB ok
23 Correct 0 ms 2492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6492 KB ok
26 Correct 1 ms 6492 KB ok
27 Correct 1 ms 6492 KB ok
28 Correct 1 ms 6492 KB ok
29 Correct 1 ms 6488 KB ok
30 Correct 1 ms 6748 KB ok
31 Correct 1 ms 6748 KB ok
32 Correct 1 ms 6748 KB ok
33 Correct 1 ms 6744 KB ok
34 Correct 1 ms 2392 KB ok
35 Correct 1 ms 2396 KB ok
36 Correct 1 ms 6748 KB ok
37 Correct 1 ms 6748 KB ok
38 Correct 1 ms 6748 KB ok
39 Correct 1 ms 6748 KB ok
40 Correct 1 ms 6748 KB ok
41 Correct 1 ms 6748 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 0 ms 2396 KB ok
4 Correct 0 ms 2396 KB ok
5 Correct 0 ms 2396 KB ok
6 Correct 1 ms 6488 KB ok
7 Correct 1 ms 6492 KB ok
8 Correct 1 ms 6488 KB ok
9 Correct 1 ms 6488 KB ok
10 Correct 1 ms 6492 KB ok
11 Correct 0 ms 2396 KB ok
12 Correct 0 ms 2392 KB ok
13 Correct 1 ms 6492 KB ok
14 Correct 1 ms 6628 KB ok
15 Correct 1 ms 6492 KB ok
16 Correct 0 ms 2396 KB ok
17 Correct 1 ms 6492 KB ok
18 Correct 1 ms 6492 KB ok
19 Correct 1 ms 6492 KB ok
20 Correct 1 ms 6488 KB ok
21 Correct 1 ms 6492 KB ok
22 Correct 1 ms 2396 KB ok
23 Correct 0 ms 2492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6492 KB ok
26 Correct 1 ms 6492 KB ok
27 Correct 1 ms 6492 KB ok
28 Correct 1 ms 6492 KB ok
29 Correct 1 ms 6488 KB ok
30 Correct 1 ms 6748 KB ok
31 Correct 1 ms 6748 KB ok
32 Correct 1 ms 6748 KB ok
33 Correct 1 ms 6744 KB ok
34 Correct 1 ms 2392 KB ok
35 Correct 1 ms 2396 KB ok
36 Correct 1 ms 6748 KB ok
37 Correct 1 ms 6748 KB ok
38 Correct 1 ms 6748 KB ok
39 Correct 1 ms 6748 KB ok
40 Correct 1 ms 6748 KB ok
41 Correct 1 ms 6748 KB ok
42 Correct 380 ms 17012 KB ok
43 Correct 409 ms 17008 KB ok
44 Correct 349 ms 16976 KB ok
45 Correct 314 ms 17012 KB ok
46 Correct 321 ms 16912 KB ok
47 Correct 277 ms 16984 KB ok
48 Correct 15 ms 11868 KB ok
49 Correct 265 ms 17020 KB ok
50 Correct 275 ms 17232 KB ok
51 Correct 286 ms 17012 KB ok
52 Correct 229 ms 17020 KB ok
53 Correct 216 ms 16988 KB ok
54 Correct 276 ms 16976 KB ok
55 Correct 247 ms 17016 KB ok
56 Correct 239 ms 16976 KB ok
57 Correct 272 ms 16988 KB ok
58 Correct 269 ms 16984 KB ok
59 Correct 302 ms 17012 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6488 KB ok
2 Correct 0 ms 2396 KB ok
3 Correct 0 ms 2396 KB ok
4 Correct 0 ms 2396 KB ok
5 Correct 0 ms 2396 KB ok
6 Correct 1 ms 2392 KB ok
7 Correct 1 ms 2392 KB ok
8 Correct 1 ms 2908 KB ok
9 Correct 14 ms 11352 KB ok
10 Correct 205 ms 71436 KB ok
11 Correct 1 ms 6488 KB ok
12 Correct 1 ms 6492 KB ok
13 Correct 1 ms 6488 KB ok
14 Correct 1 ms 6488 KB ok
15 Correct 1 ms 6492 KB ok
16 Correct 0 ms 2396 KB ok
17 Correct 0 ms 2392 KB ok
18 Correct 1 ms 6492 KB ok
19 Correct 1 ms 6628 KB ok
20 Correct 1 ms 6492 KB ok
21 Correct 0 ms 2396 KB ok
22 Correct 1 ms 6492 KB ok
23 Correct 1 ms 6492 KB ok
24 Correct 1 ms 6492 KB ok
25 Correct 1 ms 6488 KB ok
26 Correct 1 ms 6492 KB ok
27 Correct 1 ms 2396 KB ok
28 Correct 0 ms 2492 KB ok
29 Correct 1 ms 6492 KB ok
30 Correct 1 ms 6492 KB ok
31 Correct 1 ms 6492 KB ok
32 Correct 1 ms 6492 KB ok
33 Correct 1 ms 6492 KB ok
34 Correct 1 ms 6488 KB ok
35 Correct 1 ms 6748 KB ok
36 Correct 1 ms 6748 KB ok
37 Correct 1 ms 6748 KB ok
38 Correct 1 ms 6744 KB ok
39 Correct 1 ms 2392 KB ok
40 Correct 1 ms 2396 KB ok
41 Correct 1 ms 6748 KB ok
42 Correct 1 ms 6748 KB ok
43 Correct 1 ms 6748 KB ok
44 Correct 1 ms 6748 KB ok
45 Correct 1 ms 6748 KB ok
46 Correct 1 ms 6748 KB ok
47 Correct 380 ms 17012 KB ok
48 Correct 409 ms 17008 KB ok
49 Correct 349 ms 16976 KB ok
50 Correct 314 ms 17012 KB ok
51 Correct 321 ms 16912 KB ok
52 Correct 277 ms 16984 KB ok
53 Correct 15 ms 11868 KB ok
54 Correct 265 ms 17020 KB ok
55 Correct 275 ms 17232 KB ok
56 Correct 286 ms 17012 KB ok
57 Correct 229 ms 17020 KB ok
58 Correct 216 ms 16988 KB ok
59 Correct 276 ms 16976 KB ok
60 Correct 247 ms 17016 KB ok
61 Correct 239 ms 16976 KB ok
62 Correct 272 ms 16988 KB ok
63 Correct 269 ms 16984 KB ok
64 Correct 302 ms 17012 KB ok
65 Partially correct 216 ms 71252 KB partial
66 Partially correct 226 ms 71312 KB partial
67 Partially correct 206 ms 71504 KB partial
68 Partially correct 204 ms 71248 KB partial
69 Partially correct 208 ms 71252 KB partial
70 Partially correct 228 ms 71248 KB partial
71 Partially correct 234 ms 71252 KB partial
72 Partially correct 235 ms 71332 KB partial
73 Correct 240 ms 71324 KB ok
74 Correct 237 ms 71508 KB ok
75 Partially correct 239 ms 71328 KB partial
76 Partially correct 214 ms 71316 KB partial
77 Partially correct 253 ms 71308 KB partial
78 Partially correct 252 ms 71436 KB partial
79 Partially correct 202 ms 71312 KB partial
80 Partially correct 230 ms 71388 KB partial
81 Partially correct 228 ms 71252 KB partial
82 Partially correct 253 ms 71308 KB partial
83 Partially correct 243 ms 71504 KB partial
84 Partially correct 217 ms 71508 KB partial
85 Partially correct 217 ms 71308 KB partial
86 Partially correct 204 ms 71448 KB partial
87 Partially correct 219 ms 71508 KB partial
88 Partially correct 225 ms 71504 KB partial
89 Partially correct 221 ms 71320 KB partial
90 Partially correct 221 ms 71452 KB partial
91 Partially correct 219 ms 71512 KB partial
92 Partially correct 245 ms 71252 KB partial
93 Partially correct 200 ms 71248 KB partial
94 Partially correct 209 ms 71452 KB partial
95 Partially correct 248 ms 71312 KB partial
96 Partially correct 194 ms 71436 KB partial
97 Partially correct 220 ms 71504 KB partial
98 Partially correct 204 ms 71452 KB partial
99 Partially correct 198 ms 71252 KB partial
100 Partially correct 202 ms 71252 KB partial
101 Partially correct 203 ms 71248 KB partial
102 Partially correct 203 ms 71312 KB partial
103 Partially correct 193 ms 71248 KB partial
104 Partially correct 240 ms 71448 KB partial
105 Partially correct 195 ms 71508 KB partial
106 Partially correct 198 ms 71248 KB partial
107 Partially correct 206 ms 71328 KB partial
108 Partially correct 212 ms 71252 KB partial
109 Partially correct 200 ms 71504 KB partial