답안 #1078381

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078381 2024-08-27T16:08:57 Z Huseyn123 축구 경기장 (IOI23_soccer) C++17
6 / 100
201 ms 39488 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
int dp[31][31][31][31];
int a[31];
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
    int n=N;
    int cnt,x,y; 
    cnt=x=y=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(F[i][j]){
                x=i; 
                y=j; 
                cnt++; 
            }
        }
    }
    if(cnt==1){
        return N*N-min(x+1,N-x)*min(y+1,N-y);
    }
    int res=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int z=j;z<N;z++){
                if(F[i][z]){
                    break; 
                }
                dp[i][i][j][z]=z-j+1;
            }
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<N;j++){
            int z=j+i-1;
            if(j){
                for(int l=0;l<N;l++){
                    vector<pair<int,int>> c; 
                    int sz=0;
                    int h=l;
                    for(int r=l;r<N;r++){
                        if(F[j-1][r]){
                            if(h!=r){
                                c.push_back({h,r-1});
                                a[sz]=0;
                                sz++;
                            }
                            h=r+1;
                        }
                        else{
                            dp[j-1][z][h][r]=max(dp[j-1][z][h][r],dp[j][z][l][r]+r-h+1);
                        }
                        if(sz){
                            a[sz-1]=max(a[sz-1],dp[j][z][l][r]);
                        }
                    }
                    h=0;
                    for(int i=sz-1;i>=0;i--){
                        h=max(h,a[i]);
                        dp[j-1][z][c[i].first][c[i].second]=max(dp[j-1][z][c[i].first][c[i].second],h+c[i].second-c[i].first+1);
                    }
                }
            }
            if(z+1<N){
                for(int l=0;l<N;l++){
                    vector<pair<int,int>> c; 
                    int sz=0;
                    int h=l;
                    for(int r=l;r<N;r++){
                        if(F[z+1][r]){
                            if(h!=r){
                                c.push_back({h,r-1});
                                a[sz]=0;
                                sz++;
                            }
                            h=r+1;
                        }
                        else{
                            dp[j][z+1][h][r]=max(dp[j][z+1][h][r],dp[j][z][l][r]+r-h+1);
                        }
                        if(sz){
                            a[sz-1]=max(a[sz-1],dp[j][z][l][r]);
                        }
                    }
                    h=0;
                    for(int i=sz-1;i>=0;i--){
                        h=max(h,a[i]);
                        dp[j][z+1][c[i].first][c[i].second]=max(dp[j][z+1][c[i].first][c[i].second],h+c[i].second-c[i].first+1);
                    }
                }
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            for(int z=0;z<N;z++){
                for(int k=z;k<N;k++){
                    res=max(res,dp[i][j][z][k]);
                    //cout << i << " " << j << " " << z << " " << k << " " << dp[i][j][z][k] << "\n";
                }
            }
        }
    }
    return res; 
}

Compilation message

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:8:9: warning: unused variable 'n' [-Wunused-variable]
    8 |     int n=N;
      |         ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 1 ms 348 KB ok
4 Correct 0 ms 344 KB ok
5 Correct 0 ms 440 KB ok
6 Correct 0 ms 348 KB ok
7 Correct 2 ms 348 KB ok
8 Correct 13 ms 2908 KB ok
9 Correct 201 ms 39488 KB ok
# 결과 실행 시간 메모리 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 1 ms 348 KB ok
9 Correct 0 ms 348 KB ok
10 Correct 0 ms 348 KB ok
11 Incorrect 0 ms 348 KB wrong
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 0 ms 348 KB ok
11 Correct 0 ms 348 KB ok
12 Incorrect 0 ms 348 KB wrong
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 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
14 Incorrect 0 ms 348 KB wrong
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 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
14 Incorrect 0 ms 348 KB wrong
15 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 344 KB ok
6 Correct 0 ms 440 KB ok
7 Correct 0 ms 348 KB ok
8 Correct 2 ms 348 KB ok
9 Correct 13 ms 2908 KB ok
10 Correct 201 ms 39488 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 0 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 1 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Incorrect 0 ms 348 KB wrong
20 Halted 0 ms 0 KB -