Submission #1010396

# Submission time Handle Problem Language Result Execution time Memory
1010396 2024-06-29T04:24:09 Z thinknoexit Soccer Stadium (IOI23_soccer) C++17
8 / 100
4500 ms 71316 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 = 0;
void play(int st) {
    if (st == n + 1) {
        bool can = 1;
        int cnt = 0;
        {
            int cnt = 0;
            for (int i = 1;i <= n;i++) {
                cnt += (l[i] == 0) != (l[i - 1] == 0);
            }
            if (cnt > 2) return;
        }
        for (int i = 2;i < n;i++) {
            if (l[i - 1] < l[i] && l[i] > l[i + 1]) return;
            if (r[i - 1] > r[i] && r[i] < r[i + 1]) return;
        }
        for (int i = 1;i <= n;i++) {
            if (l[i] == 0) continue;
            cnt += r[i] - l[i] + 1;
            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) can = 0;
            }
        }
        if (can) mx = max(mx, cnt);
        return;
    }
    l[st] = r[st] = 0;
    play(st + 1);
    for (int i = 1;i <= n;i++) {
        for (int j = i;j <= n;j++) {
            l[st] = i, r[st] = j;
            if (qs[st][j] - qs[st][i - 1] == 0) play(st + 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;
    }
    play(1);
    return mx;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 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 444 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 1 ms 1376 KB ok
8 Correct 14 ms 8808 KB ok
9 Correct 233 ms 71316 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 352 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 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 600 KB ok
11 Correct 0 ms 348 KB ok
12 Partially correct 0 ms 348 KB partial
13 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB ok
2 Correct 1 ms 352 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 352 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 348 KB ok
10 Correct 0 ms 348 KB ok
11 Correct 0 ms 600 KB ok
12 Correct 0 ms 348 KB ok
13 Partially correct 0 ms 348 KB partial
14 Correct 0 ms 348 KB ok
15 Execution timed out 4522 ms 344 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB ok
2 Correct 1 ms 352 KB ok
3 Correct 0 ms 348 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 0 ms 352 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 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 600 KB ok
14 Correct 0 ms 348 KB ok
15 Partially correct 0 ms 348 KB partial
16 Correct 0 ms 348 KB ok
17 Execution timed out 4522 ms 344 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB ok
2 Correct 1 ms 352 KB ok
3 Correct 0 ms 348 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 0 ms 352 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 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 600 KB ok
14 Correct 0 ms 348 KB ok
15 Partially correct 0 ms 348 KB partial
16 Correct 0 ms 348 KB ok
17 Execution timed out 4522 ms 344 KB Time limit exceeded
18 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 348 KB ok
2 Correct 1 ms 352 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 348 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 444 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 1 ms 1376 KB ok
9 Correct 14 ms 8808 KB ok
10 Correct 233 ms 71316 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 352 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 600 KB ok
19 Correct 0 ms 348 KB ok
20 Partially correct 0 ms 348 KB partial
21 Correct 0 ms 348 KB ok
22 Execution timed out 4522 ms 344 KB Time limit exceeded
23 Halted 0 ms 0 KB -