Submission #840246

# Submission time Handle Problem Language Result Execution time Memory
840246 2023-08-31T08:41:58 Z bachhoangxuan Soccer Stadium (IOI23_soccer) C++17
8 / 100
2749 ms 41604 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=1;d2<n;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;
    }
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 340 KB partial
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Correct 0 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 852 KB ok
8 Correct 56 ms 4684 KB ok
9 Correct 2749 ms 41604 KB ok
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB ok
2 Correct 0 ms 212 KB ok
3 Partially correct 0 ms 340 KB partial
4 Partially correct 0 ms 340 KB partial
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 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
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 340 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Partially correct 0 ms 340 KB partial
5 Partially correct 0 ms 340 KB partial
6 Correct 0 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 0 ms 340 KB ok
14 Correct 0 ms 340 KB ok
15 Partially correct 0 ms 468 KB partial
16 Partially correct 0 ms 468 KB partial
17 Correct 0 ms 468 KB ok
18 Partially correct 0 ms 468 KB partial
19 Partially correct 0 ms 468 KB partial
20 Incorrect 0 ms 468 KB wrong
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 340 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Partially correct 0 ms 340 KB partial
7 Partially correct 0 ms 340 KB partial
8 Correct 0 ms 340 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 0 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 Partially correct 0 ms 468 KB partial
18 Partially correct 0 ms 468 KB partial
19 Correct 0 ms 468 KB ok
20 Partially correct 0 ms 468 KB partial
21 Partially correct 0 ms 468 KB partial
22 Incorrect 0 ms 468 KB wrong
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 340 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 ms 340 KB ok
5 Correct 0 ms 340 KB ok
6 Partially correct 0 ms 340 KB partial
7 Partially correct 0 ms 340 KB partial
8 Correct 0 ms 340 KB ok
9 Correct 0 ms 340 KB ok
10 Correct 0 ms 340 KB ok
11 Correct 0 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 Partially correct 0 ms 468 KB partial
18 Partially correct 0 ms 468 KB partial
19 Correct 0 ms 468 KB ok
20 Partially correct 0 ms 468 KB partial
21 Partially correct 0 ms 468 KB partial
22 Incorrect 0 ms 468 KB wrong
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 340 KB partial
2 Correct 0 ms 212 KB ok
3 Correct 0 ms 212 KB ok
4 Correct 0 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 852 KB ok
9 Correct 56 ms 4684 KB ok
10 Correct 2749 ms 41604 KB ok
11 Partially correct 0 ms 340 KB partial
12 Partially correct 0 ms 340 KB partial
13 Correct 0 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 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 Partially correct 0 ms 468 KB partial
23 Partially correct 0 ms 468 KB partial
24 Correct 0 ms 468 KB ok
25 Partially correct 0 ms 468 KB partial
26 Partially correct 0 ms 468 KB partial
27 Incorrect 0 ms 468 KB wrong
28 Halted 0 ms 0 KB -