Submission #845745

# Submission time Handle Problem Language Result Execution time Memory
845745 2023-09-06T15:13:26 Z Sorting Soccer Stadium (IOI23_soccer) C++17
30 / 100
4500 ms 444 KB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 7;

bool f[N][N];
int prefix[N][N];
int n;

pair<int, bool> dp[N][N][N][N];

bool bad(int l1, int r1, int l2, int r2){
    if(l1 <= l2 && r2 <= r1)
        return false;
    if(l2 <= l1 && r1 <= r2)
        return false;
    return true;
}

int solve(int i, int j, int l, int r){
    auto &[ans, solved] = dp[i][j][l][r];
    if(solved)
        return ans;

    ans = 0;
    if(l != r){
        ans = max(ans, solve(i, j, l + 1, r));
        ans = max(ans, solve(i, j, l, r - 1));
    }

    if(i != 0){
        int sum = 0;
        for(int k = l; k <= r; ++k)
            sum += f[i - 1][k];
        if(!sum){
            ans = max(ans, solve(i - 1, j, l, r) + r - l + 1);
        }
    }
    if(j != n - 1){
        int sum = 0;
        for(int k = l; k <= r; ++k)
            sum += f[j + 1][k];
        if(!sum){
            ans = max(ans, solve(i, j + 1, l, r) + r - l + 1);
        }
    }

    return ans;
}

int biggest_stadium(int _N, std::vector<std::vector<int>> F){
    n = _N;
    for(int i = 0; i < n; ++i)
        for(int j = 0; j < n; ++j)
            f[i][j] = F[i][j];

    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int l = 0; l < n; ++l){
            for(int r = l; r < n; ++r){
                if(f[i][r])
                    break;
               ans = max(ans, solve(i, i, l, r) + r - l + 1);
            }
        }
    }

    return ans;
}
/*
3
1 1 1
1 1 1
1 1 1
*/
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Execution timed out 4542 ms 420 KB Time limit exceeded
4 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 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 1 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 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 1 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 1 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Correct 65 ms 344 KB ok
16 Correct 6 ms 444 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 1 ms 344 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 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 1 ms 348 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 348 KB ok
4 Execution timed out 4542 ms 420 KB Time limit exceeded
5 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 Execution timed out 4542 ms 420 KB Time limit exceeded
5 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 Execution timed out 4542 ms 420 KB Time limit exceeded
5 Halted 0 ms 0 KB -