답안 #915914

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
915914 2024-01-24T21:52:18 Z biank 축구 경기장 (IOI23_soccer) C++17
8 / 100
1 ms 600 KB
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define SIZE(x) (int)x.size()
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define dforsn(i,s,n) for(int i=int(n)-1;i>=int(s);i--)
#define dforn(i,n) for(int i=int(n)-1;i>=0;i--)
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> ii;
const int MAXN = 5;
int f[MAXN][MAXN];
pair<ll,ii> dp[MAXN][MAXN][MAXN];
int L[MAXN][MAXN], R[MAXN][MAXN];

int n;

pair<ll,ii> solve(int l, int r, int p) {
    if(l>r) return {0LL,{-1,n}};
    if(dp[l][r][p].fst!=-1) return dp[l][r][p];
    auto calculate = [&](pair<int,ii> prev, int i) {
        auto [val,range] = prev;
        int mini = max(range.fst, L[i][p]), maxi = min(range.snd, R[i][p]);
        return (pair<ll,ii>){val+max(maxi-mini-1,0),{mini,maxi}};
    };
    return dp[l][r][p] = max(calculate(solve(l+1,r,p),l),
                            calculate(solve(l,r-1,p),r));
}

int biggest_stadium(int N, vector<vector<int>> F) {
    n=N;
    forn(i,n) forn(j,n) {
        f[i][j]=F[i][j];
    }
    forn(i,n) forn(j,n) forn(k,n) {
        dp[i][j][k].fst = -1;
    }
    forn(i,n) {
        int k=-1;
        forn(j,n) {
            if(f[i][j]==1) k=j;
            L[i][j]=k;
        }
    }
    forn(i,n) {
        int k=n;
        dforn(j,n) {
            if(f[i][j]==1) k=j;
            R[i][j]=k;
        }
    }
    ll ans = 0LL;
    forn(i,n) {
        ll curr = solve(0,n-1,i).fst;
        ans=max(ans,curr);
    }
    return int(ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Incorrect 0 ms 348 KB wrong
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 1 ms 348 KB ok
3 Correct 0 ms 344 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 344 KB ok
10 Correct 0 ms 344 KB ok
11 Correct 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 344 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 344 KB ok
11 Correct 0 ms 344 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 348 KB ok
15 Partially correct 0 ms 348 KB partial
16 Partially correct 0 ms 348 KB partial
17 Partially correct 1 ms 600 KB partial
18 Partially correct 0 ms 344 KB partial
19 Partially correct 1 ms 348 KB partial
20 Incorrect 0 ms 348 KB wrong
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Incorrect 0 ms 348 KB wrong
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Incorrect 0 ms 348 KB wrong
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB ok
2 Correct 0 ms 344 KB ok
3 Correct 1 ms 348 KB ok
4 Incorrect 0 ms 348 KB wrong
5 Halted 0 ms 0 KB -