Submission #1072322

# Submission time Handle Problem Language Result Execution time Memory
1072322 2024-08-23T17:02:50 Z sammyuri Soccer Stadium (IOI23_soccer) C++17
48 / 100
709 ms 12164 KB
#include "soccer.h"

#include <bits/stdc++.h>
using namespace std;

const int MAXN = 31;

// dp[i][j][k][l] = biggest stadium that can fit in rows i..j,
// columns k..l currently active
int dp[MAXN][MAXN][MAXN][MAXN];

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    int n = N;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j < n; j ++)
            for (int k = 0; k < n; k ++)
                for (int l = 0; l < n; l ++)
                    dp[i][j][k][l] = -1e9;
    for (int i = 0; i < n; i ++) {
        for (int k = 0; k < n; k ++) {
            for (int l = k; l < n; l ++) {
                bool free = true;
                for (int ii = k; ii <= l; ii ++)
                    if (F[i][ii])
                        free = false;
                if (!free) continue;
                dp[i][i][k][l] = l - k + 1;
            }
        }
    }
    for (int height = 2; height <= n; height ++) {
        for (int i = 0; i < n - height + 1; i ++) {
            int j = i + height - 1;
            // add on top
            for (int k = 0; k < n; k ++) {
                for (int l = k; l < n; l ++) {
                    bool free = true;
                    for (int ii = k; ii <= l; ii ++)
                        if (F[i][ii])
                            free = false;
                    if (!free) continue;
                    int best = -1e9;
                    for (int kk = k; kk >= 0; kk --)
                        for (int ll = l; ll < n; ll ++)
                            best = max(best, dp[i + 1][j][kk][ll]);
                    // cout << i << " " << j << " " << k << " " << l << " " << best << "   ";
                    dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1);
                }
            }
            // add on bottom
            for (int k = 0; k < n; k ++) {
                for (int l = k; l < n; l ++) {
                    bool free = true;
                    for (int ii = k; ii <= l; ii ++)
                        if (F[j][ii])
                            free = false;
                    if (!free) continue;
                    int best = -1e9;
                    for (int kk = k; kk >= 0; kk --)
                        for (int ll = l; ll < n; ll ++)
                            best = max(best, dp[i][j - 1][kk][ll]);
                    // cout << i << " " << j << " " << k << " " << l << " " << best << "   ";
                    dp[i][j][k][l] = max(dp[i][j][k][l], best + l - k + 1);
                }
            }
        }
    }
    int best = 0;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j < n; j ++)
            for (int k = 0; k < n; k ++)
                for (int l = 0; l < n; l ++)
                    best = max(best, dp[i][j][k][l]);
    return best;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 604 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Runtime error 17 ms 8012 KB Execution killed with signal 11
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 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 1 ms 348 KB ok
10 Correct 1 ms 348 KB ok
11 Correct 0 ms 2396 KB ok
12 Correct 1 ms 2396 KB ok
13 Correct 1 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 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 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 1 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 2396 KB ok
13 Correct 1 ms 2396 KB ok
14 Correct 1 ms 348 KB ok
15 Correct 1 ms 604 KB ok
16 Correct 0 ms 604 KB ok
17 Correct 0 ms 604 KB ok
18 Correct 0 ms 600 KB ok
19 Correct 0 ms 604 KB ok
20 Correct 1 ms 604 KB ok
21 Correct 1 ms 604 KB ok
22 Correct 0 ms 604 KB ok
23 Correct 0 ms 604 KB ok
24 Correct 0 ms 604 KB ok
25 Correct 1 ms 604 KB ok
26 Correct 0 ms 604 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 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 348 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 2396 KB ok
15 Correct 1 ms 2396 KB ok
16 Correct 1 ms 348 KB ok
17 Correct 1 ms 604 KB ok
18 Correct 0 ms 604 KB ok
19 Correct 0 ms 604 KB ok
20 Correct 0 ms 600 KB ok
21 Correct 0 ms 604 KB ok
22 Correct 1 ms 604 KB ok
23 Correct 1 ms 604 KB ok
24 Correct 0 ms 604 KB ok
25 Correct 0 ms 604 KB ok
26 Correct 0 ms 604 KB ok
27 Correct 1 ms 604 KB ok
28 Correct 0 ms 604 KB ok
29 Correct 0 ms 604 KB ok
30 Correct 18 ms 3932 KB ok
31 Correct 13 ms 3932 KB ok
32 Correct 8 ms 3932 KB ok
33 Correct 6 ms 3940 KB ok
34 Correct 9 ms 3928 KB ok
35 Correct 11 ms 3936 KB ok
36 Correct 9 ms 3932 KB ok
37 Correct 11 ms 3932 KB ok
38 Correct 9 ms 3932 KB ok
39 Correct 9 ms 3944 KB ok
40 Correct 21 ms 3932 KB ok
41 Correct 26 ms 3932 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 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 348 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 1 ms 348 KB ok
14 Correct 0 ms 2396 KB ok
15 Correct 1 ms 2396 KB ok
16 Correct 1 ms 348 KB ok
17 Correct 1 ms 604 KB ok
18 Correct 0 ms 604 KB ok
19 Correct 0 ms 604 KB ok
20 Correct 0 ms 600 KB ok
21 Correct 0 ms 604 KB ok
22 Correct 1 ms 604 KB ok
23 Correct 1 ms 604 KB ok
24 Correct 0 ms 604 KB ok
25 Correct 0 ms 604 KB ok
26 Correct 0 ms 604 KB ok
27 Correct 1 ms 604 KB ok
28 Correct 0 ms 604 KB ok
29 Correct 0 ms 604 KB ok
30 Correct 18 ms 3932 KB ok
31 Correct 13 ms 3932 KB ok
32 Correct 8 ms 3932 KB ok
33 Correct 6 ms 3940 KB ok
34 Correct 9 ms 3928 KB ok
35 Correct 11 ms 3936 KB ok
36 Correct 9 ms 3932 KB ok
37 Correct 11 ms 3932 KB ok
38 Correct 9 ms 3932 KB ok
39 Correct 9 ms 3944 KB ok
40 Correct 21 ms 3932 KB ok
41 Correct 26 ms 3932 KB ok
42 Runtime error 709 ms 12164 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 0 ms 604 KB ok
5 Correct 0 ms 604 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Runtime error 17 ms 8012 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -