답안 #844642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
844642 2023-09-05T15:21:01 Z Sorting 축구 경기장 (IOI23_soccer) C++17
30 / 100
15 ms 5968 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][N][N][2][2];

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 i1, int i2, int l1, int r1, int l2, int r2, bool c1, bool c2){
    auto &[ans, solved] = dp[i1][i2][l1][r1][l2][r2][c1][c2];
    if(solved)
        return ans;

    solved = true;
    ans = 0;

    if(c1 && i1 != 0){
        bool new_c2 = r1 - l1 >= r2 - l2;
        for(int l3 = 0; l3 < n; ++l3){
            for(int r3 = l3; r3 < n; ++r3){
                if(f[i1 - 1][r3])
                    break;

                if(bad(l3, r3, l1, r1))
                    continue;
                if(bad(l3, r3, l2, r2))
                    continue;
                if(r3 - l3 > r1 - l1)
                    continue;

                ans = max(ans, solve(i1 - 1, i2, l3, r3, l2, r2, c1, new_c2) + r3 - l3 + 1);
            }
        }
    }
    if(c2 && i2 != n - 1){
        bool new_c1 = r2 - l2 >= r1 - l1;
        for(int l3 = 0; l3 < n; ++l3){
            for(int r3 = l3; r3 < n; ++r3){
                if(f[i2 + 1][r3])
                    break;

                if(bad(l3, r3, l1, r1))
                    continue;
                if(bad(l3, r3, l2, r2))
                    continue;
                if(r3 - l3 > r2 - l2)
                    continue;

                ans = max(ans, solve(i1, i2 + 1, l1, r1, l3, r3, new_c1, c2) + r3 - l3 + 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, l, r, true, true) + r - l + 1);
            }
        }
    }

    return ans;
}
/*
3
1 1 1
1 1 1
1 1 1
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 ms 348 KB ok
3 Runtime error 15 ms 5968 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 1 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 412 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 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 412 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 2 ms 1884 KB ok
16 Correct 2 ms 1884 KB ok
17 Correct 1 ms 1116 KB ok
18 Correct 1 ms 604 KB ok
19 Correct 1 ms 604 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 604 KB ok
22 Correct 0 ms 604 KB ok
23 Correct 0 ms 604 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 1 ms 604 KB ok
26 Correct 1 ms 1116 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Runtime error 15 ms 5968 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Runtime error 15 ms 5968 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 860 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Runtime error 15 ms 5968 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -