Submission #1011297

# Submission time Handle Problem Language Result Execution time Memory
1011297 2024-06-30T09:52:03 Z boris_mihov Soccer Stadium (IOI23_soccer) C++17
48 / 100
14 ms 6492 KB
#include "soccer.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>

typedef long long llong;
const int MAXN = 30 + 10;
const int INF  = 1e9;

int n;
int p[MAXN][MAXN];
int dp[MAXN][MAXN][MAXN][MAXN];
bool bl[MAXN][MAXN][MAXN][MAXN];

inline int sum(int rowB, int colB, int rowE, int colE)
{
    return p[rowE][colE] - p[rowB - 1][colE] - p[rowE][colB - 1] + p[rowB - 1][colB - 1];
}

int f(int rowB, int colB, int rowE, int colE)
{
    if (colB > colE)
    {
        return 0;
    }

    if (rowB == 1 && rowE == n)
    {
        return 0;
    }
    
    if (bl[rowB][colB][rowE][colE])
    {
        return dp[rowB][colB][rowE][colE];
    }

    bl[rowB][colB][rowE][colE] = true;
    if (rowB > 1 && sum(rowB - 1, colB, rowB - 1, colE) == 0)
    {
        dp[rowB][colB][rowE][colE] = std::max(dp[rowB][colB][rowE][colE], (colE - colB + 1) + f(rowB - 1, colB, rowE, colE));
    }

    if (rowE < n && sum(rowE + 1, colB, rowE + 1, colE) == 0)
    {
        dp[rowB][colB][rowE][colE] = std::max(dp[rowB][colB][rowE][colE], (colE - colB + 1) + f(rowB, colB, rowE + 1, colE));
    }

    dp[rowB][colB][rowE][colE] = std::max(dp[rowB][colB][rowE][colE], f(rowB, colB + 1, rowE, colE));
    dp[rowB][colB][rowE][colE] = std::max(dp[rowB][colB][rowE][colE], f(rowB, colB, rowE, colE - 1));
    return dp[rowB][colB][rowE][colE];
}

int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    n = N;
    for (int i = 1 ; i <= n ; ++i)
    {
        for (int j = 1 ; j <= n ; ++j)
        {
            p[i][j] = p[i - 1][j] + p[i][j - 1] - p[i - 1][j - 1] + F[i - 1][j - 1];        
        }
    }

    int max = 0;
    for (int rowB = 1 ; rowB <= n ; ++rowB)
    {
        for (int colB = 1 ; colB <= n ; ++colB)
        {
            for (int rowE = rowB ; rowE <= n ; ++rowE)
            {
                for (int colE = colB ; colE <= n ; ++colE)
                {
                    if (sum(rowB, colB, rowE, colE) == 0)
                    {
                        max = std::max(max, f(rowB, colB, rowE, colE) + (rowE - rowB + 1) * (colE - colB + 1));
                    }
                }
            }
        }
    }
    return max;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 860 KB ok
4 Correct 1 ms 860 KB ok
5 Correct 1 ms 348 KB ok
6 Correct 0 ms 348 KB ok
7 Partially correct 1 ms 348 KB partial
8 Runtime error 14 ms 5004 KB Execution killed with signal 11
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 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 0 ms 348 KB ok
11 Correct 1 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 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 0 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 1 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 0 ms 604 KB ok
16 Correct 0 ms 604 KB ok
17 Correct 0 ms 604 KB ok
18 Correct 0 ms 604 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 0 ms 604 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 860 KB ok
5 Correct 1 ms 860 KB ok
6 Correct 1 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 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 1 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 604 KB ok
18 Correct 0 ms 604 KB ok
19 Correct 0 ms 604 KB ok
20 Correct 0 ms 604 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 0 ms 604 KB ok
29 Correct 0 ms 600 KB ok
30 Correct 3 ms 5724 KB ok
31 Correct 2 ms 4956 KB ok
32 Correct 2 ms 3420 KB ok
33 Correct 1 ms 1116 KB ok
34 Correct 1 ms 1372 KB ok
35 Correct 1 ms 2140 KB ok
36 Correct 1 ms 1116 KB ok
37 Correct 1 ms 1196 KB ok
38 Correct 2 ms 1628 KB ok
39 Correct 1 ms 1884 KB ok
40 Correct 5 ms 4444 KB ok
41 Correct 6 ms 6492 KB ok
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 860 KB ok
5 Correct 1 ms 860 KB ok
6 Correct 1 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 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 1 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 604 KB ok
18 Correct 0 ms 604 KB ok
19 Correct 0 ms 604 KB ok
20 Correct 0 ms 604 KB ok
21 Correct 0 ms 348 KB ok
22 Correct 1 ms 348 KB ok
23 Correct 0 ms 348 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 1 ms 348 KB ok
28 Correct 0 ms 604 KB ok
29 Correct 0 ms 600 KB ok
30 Correct 3 ms 5724 KB ok
31 Correct 2 ms 4956 KB ok
32 Correct 2 ms 3420 KB ok
33 Correct 1 ms 1116 KB ok
34 Correct 1 ms 1372 KB ok
35 Correct 1 ms 2140 KB ok
36 Correct 1 ms 1116 KB ok
37 Correct 1 ms 1196 KB ok
38 Correct 2 ms 1628 KB ok
39 Correct 1 ms 1884 KB ok
40 Correct 5 ms 4444 KB ok
41 Correct 6 ms 6492 KB ok
42 Runtime error 14 ms 4956 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 348 KB ok
4 Correct 1 ms 860 KB ok
5 Correct 1 ms 860 KB ok
6 Correct 1 ms 348 KB ok
7 Correct 0 ms 348 KB ok
8 Partially correct 1 ms 348 KB partial
9 Runtime error 14 ms 5004 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -