Submission #915924

# Submission time Handle Problem Language Result Execution time Memory
915924 2024-01-24T22:37:01 Z biank Soccer Stadium (IOI23_soccer) C++17
73 / 100
1486 ms 55808 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 pair<int,int> ii;
const int MAXN = 500;
int f[MAXN][MAXN];
int dp[MAXN][MAXN];
ii ran[MAXN][MAXN];
int L[MAXN][MAXN], R[MAXN][MAXN];

int n;

pair<int,ii> solve(int l, int r, int p) {
    if(l>r) return {0LL,{-1,n}};
    if(dp[l][r]!=-1) return {dp[l][r],ran[l][r]};
    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<int,ii>){val+max(maxi-mini-1,0),{mini,maxi}};
    };
    pair<int,ii> res = max(calculate(solve(l+1,r,p),l),
                           calculate(solve(l,r-1,p),r));
    dp[l][r]=res.fst, ran[l][r]=res.snd;
    return res;
}

int only_check(vector<vector<int>> f) {
    vector<int> l(n,n), r(n,-1);
    forn(i,n) forn(j,n) {
        if(f[i][j]==0) {
            l[i]=min(l[i],j);
            r[i]=max(r[i],j);
        }
    }
    forn(i,n) forsn(j,l[i],r[i]+1) {
        if(f[i][j]==1) return -1;
    }
    forn(i,n) forn(j,n) {
        if(l[i]>l[j] && r[i]>r[j]) return -1;
    }
    
    vector<int> c(n);
    forn(i,n) c[i]=max(r[i]-l[i]+1,0);
    int maxi = int(max_element(ALL(c)) - c.begin());
    forsn(i,maxi,n-1) {
        if(c[i]<c[i+1]) return -1;
    }
    forn(i,maxi) {
        if(c[i]>c[i+1]) return -1;
    }
    int count=0;
    forn(i,n) forn(j,n) {
        count += f[i][j]==0;
    }
    return count;
}



int biggest_stadium(int N, vector<vector<int>> F) {
    n=N;
    if(n>500) return only_check(F);
    forn(i,n) forn(j,n) {
        f[i][j]=F[i][j];
    }
    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;
        }
    }
    int ans=0;
    forn(i,n) {
        memset(dp,-1,sizeof dp);
        ans=max(ans,solve(0,n-1,i).fst);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB ok
2 Correct 1 ms 4956 KB ok
3 Correct 1 ms 4956 KB ok
4 Correct 2 ms 4956 KB ok
5 Correct 1 ms 4956 KB ok
6 Correct 1 ms 4956 KB ok
7 Correct 15 ms 5620 KB ok
8 Correct 1098 ms 8344 KB ok
9 Partially correct 269 ms 47600 KB partial
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB ok
2 Correct 1 ms 4956 KB ok
3 Correct 1 ms 4952 KB ok
4 Correct 1 ms 4956 KB ok
5 Correct 1 ms 4956 KB ok
6 Correct 1 ms 4956 KB ok
7 Correct 1 ms 4956 KB ok
8 Correct 2 ms 4956 KB ok
9 Correct 1 ms 4956 KB ok
10 Correct 1 ms 4952 KB ok
11 Correct 1 ms 4952 KB ok
12 Correct 1 ms 4956 KB ok
13 Correct 1 ms 4956 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB ok
2 Correct 2 ms 4952 KB ok
3 Correct 1 ms 4956 KB ok
4 Correct 1 ms 4952 KB ok
5 Correct 1 ms 4956 KB ok
6 Correct 1 ms 4956 KB ok
7 Correct 1 ms 4956 KB ok
8 Correct 1 ms 4956 KB ok
9 Correct 2 ms 4956 KB ok
10 Correct 1 ms 4956 KB ok
11 Correct 1 ms 4952 KB ok
12 Correct 1 ms 4952 KB ok
13 Correct 1 ms 4956 KB ok
14 Correct 1 ms 4956 KB ok
15 Correct 1 ms 4956 KB ok
16 Correct 1 ms 4956 KB ok
17 Correct 2 ms 4952 KB ok
18 Correct 1 ms 4956 KB ok
19 Correct 2 ms 5208 KB ok
20 Correct 1 ms 4956 KB ok
21 Correct 2 ms 4956 KB ok
22 Correct 1 ms 5100 KB ok
23 Correct 1 ms 4956 KB ok
24 Correct 2 ms 4956 KB ok
25 Correct 1 ms 5036 KB ok
26 Correct 1 ms 4956 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB ok
2 Correct 2 ms 4952 KB ok
3 Correct 1 ms 4956 KB ok
4 Correct 1 ms 4956 KB ok
5 Correct 2 ms 4956 KB ok
6 Correct 1 ms 4952 KB ok
7 Correct 1 ms 4956 KB ok
8 Correct 1 ms 4956 KB ok
9 Correct 1 ms 4956 KB ok
10 Correct 1 ms 4956 KB ok
11 Correct 2 ms 4956 KB ok
12 Correct 1 ms 4956 KB ok
13 Correct 1 ms 4952 KB ok
14 Correct 1 ms 4952 KB ok
15 Correct 1 ms 4956 KB ok
16 Correct 1 ms 4956 KB ok
17 Correct 1 ms 4956 KB ok
18 Correct 1 ms 4956 KB ok
19 Correct 2 ms 4952 KB ok
20 Correct 1 ms 4956 KB ok
21 Correct 2 ms 5208 KB ok
22 Correct 1 ms 4956 KB ok
23 Correct 2 ms 4956 KB ok
24 Correct 1 ms 5100 KB ok
25 Correct 1 ms 4956 KB ok
26 Correct 2 ms 4956 KB ok
27 Correct 1 ms 5036 KB ok
28 Correct 1 ms 4956 KB ok
29 Correct 1 ms 4956 KB ok
30 Correct 2 ms 5208 KB ok
31 Correct 2 ms 5212 KB ok
32 Correct 2 ms 5212 KB ok
33 Correct 3 ms 5212 KB ok
34 Correct 2 ms 5212 KB ok
35 Correct 3 ms 5208 KB ok
36 Correct 2 ms 5208 KB ok
37 Correct 2 ms 5212 KB ok
38 Correct 2 ms 5212 KB ok
39 Correct 2 ms 5212 KB ok
40 Correct 2 ms 5212 KB ok
41 Correct 2 ms 5212 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB ok
2 Correct 2 ms 4952 KB ok
3 Correct 1 ms 4956 KB ok
4 Correct 1 ms 4956 KB ok
5 Correct 2 ms 4956 KB ok
6 Correct 1 ms 4952 KB ok
7 Correct 1 ms 4956 KB ok
8 Correct 1 ms 4956 KB ok
9 Correct 1 ms 4956 KB ok
10 Correct 1 ms 4956 KB ok
11 Correct 2 ms 4956 KB ok
12 Correct 1 ms 4956 KB ok
13 Correct 1 ms 4952 KB ok
14 Correct 1 ms 4952 KB ok
15 Correct 1 ms 4956 KB ok
16 Correct 1 ms 4956 KB ok
17 Correct 1 ms 4956 KB ok
18 Correct 1 ms 4956 KB ok
19 Correct 2 ms 4952 KB ok
20 Correct 1 ms 4956 KB ok
21 Correct 2 ms 5208 KB ok
22 Correct 1 ms 4956 KB ok
23 Correct 2 ms 4956 KB ok
24 Correct 1 ms 5100 KB ok
25 Correct 1 ms 4956 KB ok
26 Correct 2 ms 4956 KB ok
27 Correct 1 ms 5036 KB ok
28 Correct 1 ms 4956 KB ok
29 Correct 1 ms 4956 KB ok
30 Correct 2 ms 5208 KB ok
31 Correct 2 ms 5212 KB ok
32 Correct 2 ms 5212 KB ok
33 Correct 3 ms 5212 KB ok
34 Correct 2 ms 5212 KB ok
35 Correct 3 ms 5208 KB ok
36 Correct 2 ms 5208 KB ok
37 Correct 2 ms 5212 KB ok
38 Correct 2 ms 5212 KB ok
39 Correct 2 ms 5212 KB ok
40 Correct 2 ms 5212 KB ok
41 Correct 2 ms 5212 KB ok
42 Correct 1118 ms 8532 KB ok
43 Correct 1120 ms 8284 KB ok
44 Correct 1470 ms 8348 KB ok
45 Correct 1095 ms 8528 KB ok
46 Correct 1134 ms 8528 KB ok
47 Correct 1069 ms 8344 KB ok
48 Correct 1097 ms 8540 KB ok
49 Correct 1478 ms 8528 KB ok
50 Correct 1125 ms 8348 KB ok
51 Correct 1467 ms 8348 KB ok
52 Correct 1485 ms 8272 KB ok
53 Correct 1486 ms 8348 KB ok
54 Correct 1481 ms 8344 KB ok
55 Correct 1096 ms 8348 KB ok
56 Correct 1466 ms 8348 KB ok
57 Correct 1473 ms 8344 KB ok
58 Correct 1091 ms 8352 KB ok
59 Correct 1464 ms 8348 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4956 KB ok
2 Correct 2 ms 4952 KB ok
3 Correct 1 ms 4956 KB ok
4 Correct 1 ms 4956 KB ok
5 Correct 2 ms 4956 KB ok
6 Correct 1 ms 4956 KB ok
7 Correct 1 ms 4956 KB ok
8 Correct 15 ms 5620 KB ok
9 Correct 1098 ms 8344 KB ok
10 Partially correct 269 ms 47600 KB partial
11 Correct 1 ms 4952 KB ok
12 Correct 1 ms 4956 KB ok
13 Correct 1 ms 4956 KB ok
14 Correct 1 ms 4956 KB ok
15 Correct 1 ms 4956 KB ok
16 Correct 2 ms 4956 KB ok
17 Correct 1 ms 4956 KB ok
18 Correct 1 ms 4952 KB ok
19 Correct 1 ms 4952 KB ok
20 Correct 1 ms 4956 KB ok
21 Correct 1 ms 4956 KB ok
22 Correct 1 ms 4956 KB ok
23 Correct 1 ms 4956 KB ok
24 Correct 2 ms 4952 KB ok
25 Correct 1 ms 4956 KB ok
26 Correct 2 ms 5208 KB ok
27 Correct 1 ms 4956 KB ok
28 Correct 2 ms 4956 KB ok
29 Correct 1 ms 5100 KB ok
30 Correct 1 ms 4956 KB ok
31 Correct 2 ms 4956 KB ok
32 Correct 1 ms 5036 KB ok
33 Correct 1 ms 4956 KB ok
34 Correct 1 ms 4956 KB ok
35 Correct 2 ms 5208 KB ok
36 Correct 2 ms 5212 KB ok
37 Correct 2 ms 5212 KB ok
38 Correct 3 ms 5212 KB ok
39 Correct 2 ms 5212 KB ok
40 Correct 3 ms 5208 KB ok
41 Correct 2 ms 5208 KB ok
42 Correct 2 ms 5212 KB ok
43 Correct 2 ms 5212 KB ok
44 Correct 2 ms 5212 KB ok
45 Correct 2 ms 5212 KB ok
46 Correct 2 ms 5212 KB ok
47 Correct 1118 ms 8532 KB ok
48 Correct 1120 ms 8284 KB ok
49 Correct 1470 ms 8348 KB ok
50 Correct 1095 ms 8528 KB ok
51 Correct 1134 ms 8528 KB ok
52 Correct 1069 ms 8344 KB ok
53 Correct 1097 ms 8540 KB ok
54 Correct 1478 ms 8528 KB ok
55 Correct 1125 ms 8348 KB ok
56 Correct 1467 ms 8348 KB ok
57 Correct 1485 ms 8272 KB ok
58 Correct 1486 ms 8348 KB ok
59 Correct 1481 ms 8344 KB ok
60 Correct 1096 ms 8348 KB ok
61 Correct 1466 ms 8348 KB ok
62 Correct 1473 ms 8344 KB ok
63 Correct 1091 ms 8352 KB ok
64 Correct 1464 ms 8348 KB ok
65 Partially correct 264 ms 47392 KB partial
66 Partially correct 287 ms 47388 KB partial
67 Partially correct 272 ms 47388 KB partial
68 Partially correct 280 ms 47392 KB partial
69 Partially correct 259 ms 47440 KB partial
70 Partially correct 272 ms 47408 KB partial
71 Partially correct 271 ms 47448 KB partial
72 Partially correct 273 ms 47396 KB partial
73 Correct 275 ms 47392 KB ok
74 Correct 269 ms 47396 KB ok
75 Partially correct 264 ms 47388 KB partial
76 Partially correct 265 ms 47384 KB partial
77 Partially correct 273 ms 47400 KB partial
78 Partially correct 287 ms 47444 KB partial
79 Partially correct 264 ms 47632 KB partial
80 Partially correct 266 ms 47444 KB partial
81 Partially correct 263 ms 47392 KB partial
82 Partially correct 274 ms 47404 KB partial
83 Partially correct 290 ms 47396 KB partial
84 Partially correct 269 ms 47388 KB partial
85 Partially correct 279 ms 55412 KB partial
86 Partially correct 272 ms 55452 KB partial
87 Partially correct 285 ms 55596 KB partial
88 Partially correct 269 ms 55448 KB partial
89 Partially correct 262 ms 55392 KB partial
90 Partially correct 275 ms 55316 KB partial
91 Partially correct 276 ms 55220 KB partial
92 Partially correct 268 ms 55384 KB partial
93 Partially correct 267 ms 55380 KB partial
94 Partially correct 263 ms 55376 KB partial
95 Partially correct 261 ms 55456 KB partial
96 Partially correct 274 ms 55452 KB partial
97 Partially correct 269 ms 55356 KB partial
98 Partially correct 259 ms 55464 KB partial
99 Partially correct 263 ms 55312 KB partial
100 Partially correct 271 ms 55316 KB partial
101 Partially correct 277 ms 55808 KB partial
102 Partially correct 272 ms 55376 KB partial
103 Partially correct 265 ms 55320 KB partial
104 Partially correct 273 ms 55380 KB partial
105 Partially correct 260 ms 55452 KB partial
106 Partially correct 267 ms 55328 KB partial
107 Partially correct 271 ms 55380 KB partial
108 Partially correct 263 ms 55324 KB partial
109 Partially correct 263 ms 55384 KB partial