답안 #840250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
840250 2023-08-31T08:43:29 Z bachhoangxuan 축구 경기장 (IOI23_soccer) C++17
65.5 / 100
3831 ms 49952 KB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define fi first
#define se second
const int maxn=2005;
const int inf=1e9;
int f[maxn][maxn],Max[maxn][maxn];

int dp[35][35][35][35];
int cur[35][35][35];

int biggest_stadium(int n, std::vector<std::vector<int>> F)
{
    for(int i=0;i<n;i++) for(int j=0;j<n;j++) for(int k=0;k<n;k++) cur[i][j][k]=-inf;

    int x=-1,y=-1,cnt=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) if(F[i][j]==1) x=i,y=j,cnt++;
    }
    if(cnt==1) return n*n-min(x+1,n-x)*min(y+1,n-y);
    if(n<=30){
        for(int i=0;i<n;i++){
            int l=0;
            for(int j=0;j<n;j++){
                if(F[i][j]){
                    for(int s=l;s<j;s++) for(int t=s;t<j;t++) cur[i][s][t]=t-s+1;
                    l=j+1;
                }
            }
            for(int s=l;s<n;s++) for(int t=s;t<n;t++) cur[i][s][t]=t-s+1;
        }
        int ans=0;
        for(int d=0;d<n;d++){
            for(int l=0;l+d<n;l++){
                int r=l+d;
                for(int i=0;i<n;i++) for(int j=i;j<n;j++){
                    if(d==0) dp[l][r][i][j]=cur[l][i][j];
                    else dp[l][r][i][j]=max(dp[l+1][r][i][j]+cur[l][i][j],dp[l][r-1][i][j]+cur[r][i][j]);
                    dp[l][r][i][j]=max(dp[l][r][i][j],-inf);
                    ans=max(ans,dp[l][r][i][j]);
                }
                for(int d2=n-1;d2>=1;d2--) for(int i=0;i+d2<n;i++){
                    int j=i+d2;
                    dp[l][r][i+1][j]=max(dp[l][r][i+1][j],dp[l][r][i][j]);
                    dp[l][r][i][j-1]=max(dp[l][r][i][j-1],dp[l][r][i][j]);
                }
            }
        }
        return ans;
    }
    else{
        vector<pii> p;
        for(int i=0;i<n;i++){
            int l=0;
            for(int j=0;j<n;j++){
                if(F[i][j]){
                    if(l<j) p.push_back({l,1-j});
                    l=j+1;
                }
            }
            if(l<n) p.push_back({l,1-n});
        }
        sort(p.begin(),p.end());
        for(int i=1;i<(int)p.size();i++) if(p[i].se<p[i-1].se) return 0;

        p.clear();
        for(int i=0;i<n;i++){
            int l=0;
            for(int j=0;j<n;j++){
                if(F[j][i]){
                    if(l<j) p.push_back({l,1-j});
                    l=j+1;
                }
            }
            if(l<n) p.push_back({l,1-n});
        }
        sort(p.begin(),p.end());
        for(int i=1;i<(int)p.size();i++) if(p[i].se<p[i-1].se) return 0;
        return n*n-cnt;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 1 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 212 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 1 ms 860 KB ok
8 Correct 65 ms 4620 KB ok
9 Correct 2958 ms 41548 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 1 ms 340 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 0 ms 340 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 1 ms 340 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 1 ms 340 KB ok
11 Correct 0 ms 340 KB ok
12 Correct 0 ms 340 KB ok
13 Correct 0 ms 340 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 1 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 0 ms 340 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 0 ms 340 KB ok
9 Correct 1 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 0 ms 340 KB ok
13 Correct 0 ms 340 KB ok
14 Correct 0 ms 340 KB ok
15 Correct 0 ms 468 KB ok
16 Correct 0 ms 468 KB ok
17 Correct 0 ms 468 KB ok
18 Correct 0 ms 468 KB ok
19 Correct 1 ms 468 KB ok
20 Correct 0 ms 468 KB ok
21 Correct 0 ms 468 KB ok
22 Correct 0 ms 468 KB ok
23 Correct 0 ms 468 KB ok
24 Correct 0 ms 468 KB ok
25 Correct 0 ms 468 KB ok
26 Correct 0 ms 468 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 1 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 1 ms 340 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 0 ms 340 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 0 ms 340 KB ok
13 Correct 1 ms 340 KB ok
14 Correct 0 ms 340 KB ok
15 Correct 0 ms 340 KB ok
16 Correct 0 ms 340 KB ok
17 Correct 0 ms 468 KB ok
18 Correct 0 ms 468 KB ok
19 Correct 0 ms 468 KB ok
20 Correct 0 ms 468 KB ok
21 Correct 1 ms 468 KB ok
22 Correct 0 ms 468 KB ok
23 Correct 0 ms 468 KB ok
24 Correct 0 ms 468 KB ok
25 Correct 0 ms 468 KB ok
26 Correct 0 ms 468 KB ok
27 Correct 0 ms 468 KB ok
28 Correct 0 ms 468 KB ok
29 Correct 0 ms 468 KB ok
30 Correct 2 ms 2772 KB ok
31 Correct 3 ms 2772 KB ok
32 Correct 2 ms 2772 KB ok
33 Correct 2 ms 2772 KB ok
34 Correct 2 ms 2772 KB ok
35 Correct 2 ms 2772 KB ok
36 Correct 2 ms 2772 KB ok
37 Correct 2 ms 2728 KB ok
38 Correct 2 ms 2772 KB ok
39 Correct 2 ms 2772 KB ok
40 Correct 2 ms 2772 KB ok
41 Correct 2 ms 2772 KB ok
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 1 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 1 ms 340 KB ok
7 Correct 0 ms 340 KB ok
8 Correct 0 ms 340 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 0 ms 340 KB ok
13 Correct 1 ms 340 KB ok
14 Correct 0 ms 340 KB ok
15 Correct 0 ms 340 KB ok
16 Correct 0 ms 340 KB ok
17 Correct 0 ms 468 KB ok
18 Correct 0 ms 468 KB ok
19 Correct 0 ms 468 KB ok
20 Correct 0 ms 468 KB ok
21 Correct 1 ms 468 KB ok
22 Correct 0 ms 468 KB ok
23 Correct 0 ms 468 KB ok
24 Correct 0 ms 468 KB ok
25 Correct 0 ms 468 KB ok
26 Correct 0 ms 468 KB ok
27 Correct 0 ms 468 KB ok
28 Correct 0 ms 468 KB ok
29 Correct 0 ms 468 KB ok
30 Correct 2 ms 2772 KB ok
31 Correct 3 ms 2772 KB ok
32 Correct 2 ms 2772 KB ok
33 Correct 2 ms 2772 KB ok
34 Correct 2 ms 2772 KB ok
35 Correct 2 ms 2772 KB ok
36 Correct 2 ms 2772 KB ok
37 Correct 2 ms 2728 KB ok
38 Correct 2 ms 2772 KB ok
39 Correct 2 ms 2772 KB ok
40 Correct 2 ms 2772 KB ok
41 Correct 2 ms 2772 KB ok
42 Partially correct 59 ms 5076 KB partial
43 Partially correct 61 ms 5316 KB partial
44 Partially correct 75 ms 4744 KB partial
45 Partially correct 59 ms 4740 KB partial
46 Partially correct 59 ms 4876 KB partial
47 Partially correct 56 ms 4644 KB partial
48 Correct 69 ms 4684 KB ok
49 Partially correct 57 ms 4676 KB partial
50 Partially correct 60 ms 5300 KB partial
51 Partially correct 66 ms 5012 KB partial
52 Partially correct 57 ms 4668 KB partial
53 Partially correct 57 ms 4724 KB partial
54 Partially correct 57 ms 4744 KB partial
55 Partially correct 57 ms 4672 KB partial
56 Partially correct 56 ms 4688 KB partial
57 Partially correct 59 ms 4748 KB partial
58 Partially correct 57 ms 4768 KB partial
59 Partially correct 56 ms 4688 KB partial
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 1 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Correct 0 ms 212 KB ok
7 Correct 0 ms 212 KB ok
8 Correct 1 ms 860 KB ok
9 Correct 65 ms 4620 KB ok
10 Correct 2958 ms 41548 KB ok
11 Correct 1 ms 340 KB ok
12 Correct 0 ms 340 KB ok
13 Correct 0 ms 340 KB ok
14 Correct 0 ms 340 KB ok
15 Correct 0 ms 340 KB ok
16 Correct 1 ms 340 KB ok
17 Correct 0 ms 340 KB ok
18 Correct 1 ms 340 KB ok
19 Correct 0 ms 340 KB ok
20 Correct 0 ms 340 KB ok
21 Correct 0 ms 340 KB ok
22 Correct 0 ms 468 KB ok
23 Correct 0 ms 468 KB ok
24 Correct 0 ms 468 KB ok
25 Correct 0 ms 468 KB ok
26 Correct 1 ms 468 KB ok
27 Correct 0 ms 468 KB ok
28 Correct 0 ms 468 KB ok
29 Correct 0 ms 468 KB ok
30 Correct 0 ms 468 KB ok
31 Correct 0 ms 468 KB ok
32 Correct 0 ms 468 KB ok
33 Correct 0 ms 468 KB ok
34 Correct 0 ms 468 KB ok
35 Correct 2 ms 2772 KB ok
36 Correct 3 ms 2772 KB ok
37 Correct 2 ms 2772 KB ok
38 Correct 2 ms 2772 KB ok
39 Correct 2 ms 2772 KB ok
40 Correct 2 ms 2772 KB ok
41 Correct 2 ms 2772 KB ok
42 Correct 2 ms 2728 KB ok
43 Correct 2 ms 2772 KB ok
44 Correct 2 ms 2772 KB ok
45 Correct 2 ms 2772 KB ok
46 Correct 2 ms 2772 KB ok
47 Partially correct 59 ms 5076 KB partial
48 Partially correct 61 ms 5316 KB partial
49 Partially correct 75 ms 4744 KB partial
50 Partially correct 59 ms 4740 KB partial
51 Partially correct 59 ms 4876 KB partial
52 Partially correct 56 ms 4644 KB partial
53 Correct 69 ms 4684 KB ok
54 Partially correct 57 ms 4676 KB partial
55 Partially correct 60 ms 5300 KB partial
56 Partially correct 66 ms 5012 KB partial
57 Partially correct 57 ms 4668 KB partial
58 Partially correct 57 ms 4724 KB partial
59 Partially correct 57 ms 4744 KB partial
60 Partially correct 57 ms 4672 KB partial
61 Partially correct 56 ms 4688 KB partial
62 Partially correct 59 ms 4748 KB partial
63 Partially correct 57 ms 4768 KB partial
64 Partially correct 56 ms 4688 KB partial
65 Partially correct 2861 ms 45836 KB partial
66 Partially correct 3831 ms 49900 KB partial
67 Partially correct 3026 ms 45832 KB partial
68 Partially correct 2964 ms 41648 KB partial
69 Partially correct 2937 ms 42220 KB partial
70 Partially correct 2972 ms 42708 KB partial
71 Partially correct 2934 ms 41664 KB partial
72 Partially correct 2778 ms 41632 KB partial
73 Correct 2764 ms 41612 KB ok
74 Correct 2884 ms 41528 KB ok
75 Partially correct 2809 ms 41620 KB partial
76 Partially correct 2896 ms 49888 KB partial
77 Partially correct 2911 ms 49952 KB partial
78 Partially correct 2841 ms 43704 KB partial
79 Partially correct 2859 ms 42716 KB partial
80 Partially correct 2787 ms 42248 KB partial
81 Partially correct 2895 ms 42172 KB partial
82 Partially correct 2908 ms 42208 KB partial
83 Partially correct 2793 ms 45816 KB partial
84 Partially correct 2766 ms 41608 KB partial
85 Partially correct 2822 ms 41616 KB partial
86 Partially correct 2798 ms 41536 KB partial
87 Partially correct 2790 ms 41656 KB partial
88 Partially correct 2797 ms 41692 KB partial
89 Partially correct 2829 ms 41624 KB partial
90 Partially correct 2756 ms 41552 KB partial
91 Partially correct 2785 ms 41592 KB partial
92 Partially correct 2823 ms 43724 KB partial
93 Partially correct 2799 ms 43784 KB partial
94 Partially correct 2816 ms 42688 KB partial
95 Partially correct 2963 ms 42220 KB partial
96 Partially correct 2827 ms 41980 KB partial
97 Partially correct 3078 ms 41964 KB partial
98 Partially correct 2866 ms 41784 KB partial
99 Partially correct 2753 ms 43812 KB partial
100 Partially correct 2832 ms 41604 KB partial
101 Partially correct 2782 ms 41564 KB partial
102 Partially correct 2799 ms 41552 KB partial
103 Partially correct 2797 ms 41640 KB partial
104 Partially correct 2748 ms 41660 KB partial
105 Partially correct 2740 ms 41692 KB partial
106 Partially correct 2790 ms 41640 KB partial
107 Partially correct 2804 ms 41696 KB partial
108 Partially correct 2821 ms 45836 KB partial
109 Partially correct 2831 ms 45828 KB partial