답안 #1078501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078501 2024-08-27T18:56:52 Z Huseyn123 축구 경기장 (IOI23_soccer) C++17
54 / 100
204 ms 39760 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;
                        }
                        if(!dp[j][z][l][r]){
                            continue; 
                        }
                        if(!F[j-1][r]){
                            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]);
                        if(h==0){
                            continue; 
                        }
                        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;
                        }
                        if(!dp[j][z][l][r]){
                            continue; 
                        }
                        if(!F[z+1][r]){
                            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]);
                        if(h==0){
                            continue;
                        }
                        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 0 ms 348 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 1 ms 348 KB ok
8 Correct 12 ms 2832 KB ok
9 Correct 204 ms 39760 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB ok
2 Correct 0 ms 348 KB ok
3 Correct 0 ms 344 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 0 ms 348 KB ok
12 Correct 0 ms 348 KB ok
13 Correct 0 ms 344 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 344 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 0 ms 348 KB ok
13 Correct 0 ms 348 KB ok
14 Correct 0 ms 344 KB ok
15 Correct 0 ms 344 KB ok
16 Correct 0 ms 356 KB ok
17 Correct 1 ms 348 KB ok
18 Correct 1 ms 348 KB ok
19 Correct 0 ms 344 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 1 ms 348 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 0 ms 348 KB ok
26 Correct 0 ms 348 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 344 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 0 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 ms 356 KB ok
19 Correct 1 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 348 KB ok
30 Correct 4 ms 2136 KB ok
31 Correct 5 ms 1884 KB ok
32 Correct 5 ms 860 KB ok
33 Correct 3 ms 604 KB ok
34 Correct 4 ms 1884 KB ok
35 Correct 3 ms 1116 KB ok
36 Correct 3 ms 976 KB ok
37 Correct 3 ms 860 KB ok
38 Correct 3 ms 1116 KB ok
39 Correct 3 ms 1232 KB ok
40 Correct 3 ms 1368 KB ok
41 Correct 5 ms 2140 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 344 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 0 ms 348 KB ok
15 Correct 0 ms 348 KB ok
16 Correct 0 ms 344 KB ok
17 Correct 0 ms 344 KB ok
18 Correct 0 ms 356 KB ok
19 Correct 1 ms 348 KB ok
20 Correct 1 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 348 KB ok
23 Correct 1 ms 348 KB ok
24 Correct 0 ms 348 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 0 ms 348 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 0 ms 348 KB ok
29 Correct 1 ms 348 KB ok
30 Correct 4 ms 2136 KB ok
31 Correct 5 ms 1884 KB ok
32 Correct 5 ms 860 KB ok
33 Correct 3 ms 604 KB ok
34 Correct 4 ms 1884 KB ok
35 Correct 3 ms 1116 KB ok
36 Correct 3 ms 976 KB ok
37 Correct 3 ms 860 KB ok
38 Correct 3 ms 1116 KB ok
39 Correct 3 ms 1232 KB ok
40 Correct 3 ms 1368 KB ok
41 Correct 5 ms 2140 KB ok
42 Runtime error 17 ms 9052 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 12 ms 2832 KB ok
10 Correct 204 ms 39760 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 Correct 0 ms 348 KB ok
16 Correct 0 ms 348 KB ok
17 Correct 0 ms 348 KB ok
18 Correct 0 ms 348 KB ok
19 Correct 0 ms 348 KB ok
20 Correct 0 ms 348 KB ok
21 Correct 0 ms 344 KB ok
22 Correct 0 ms 344 KB ok
23 Correct 0 ms 356 KB ok
24 Correct 1 ms 348 KB ok
25 Correct 1 ms 348 KB ok
26 Correct 0 ms 344 KB ok
27 Correct 0 ms 348 KB ok
28 Correct 1 ms 348 KB ok
29 Correct 0 ms 348 KB ok
30 Correct 1 ms 348 KB ok
31 Correct 0 ms 348 KB ok
32 Correct 0 ms 348 KB ok
33 Correct 0 ms 348 KB ok
34 Correct 1 ms 348 KB ok
35 Correct 4 ms 2136 KB ok
36 Correct 5 ms 1884 KB ok
37 Correct 5 ms 860 KB ok
38 Correct 3 ms 604 KB ok
39 Correct 4 ms 1884 KB ok
40 Correct 3 ms 1116 KB ok
41 Correct 3 ms 976 KB ok
42 Correct 3 ms 860 KB ok
43 Correct 3 ms 1116 KB ok
44 Correct 3 ms 1232 KB ok
45 Correct 3 ms 1368 KB ok
46 Correct 5 ms 2140 KB ok
47 Runtime error 17 ms 9052 KB Execution killed with signal 11
48 Halted 0 ms 0 KB -