Submission #930087

# Submission time Handle Problem Language Result Execution time Memory
930087 2024-02-18T12:53:11 Z abcvuitunggio Soccer Stadium (IOI23_soccer) C++17
100 / 100
799 ms 161876 KB
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
const int mxn=2006;
int ans,dp[mxn][mxn],l[mxn][mxn],u[mxn][mxn],d[mxn][mxn],r[mxn][mxn],L[mxn],R[mxn],h[mxn][mxn],w[mxn][mxn],a[mxn][mxn];
vector <int> ve[mxn];
int biggest_stadium(int n, vector <vector <int>> F){
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++){
            l[i][j]=(j&&!F[i][j-1]?l[i][j-1]:j);
            r[i][j]=(j<n-1&&!F[i][j+1]);
            d[i][j]=n-1;
        }
    for (int j=n-1;j>=0;j--){
        stack <int> st;
        for (int i=0;i<n;i++){
            if (!F[i][j])
                ve[l[i][j]].push_back(i);
            while (!st.empty()&&(F[i][j]||l[i][j]>l[st.top()][j])){
                d[st.top()][j]=i-1;
                st.pop();
            }
            L[i]=(st.empty()?-1:st.top());
            if (!F[i][j])
                st.push(i);
        }
        while (!st.empty())
            st.pop();
        for (int i=n-1;i>=0;i--){
            while (!st.empty()&&(F[i][j]||l[i][j]>l[st.top()][j])){
                u[st.top()][j]=i+1;
                st.pop();
            }
            R[i]=(st.empty()?-1:st.top());
            if (!F[i][j])
                st.push(i);
        }
        for (int i=0;i<n;i++){
            h[i][j]=d[i][j]-u[i][j]+1;
            w[i][j]=j-l[i][j]+1;
            a[i][j]=w[i][j]*h[i][j];
            if (r[i][j])
                dp[i][j]=max(dp[i][j+1]-w[i][j]*h[i][j+1],0);
            dp[i][j]+=a[i][j];
        }
        for (int k=0;k<=j;k++)
            for (int it=0;it<2;it++){
                reverse(ve[k].begin(),ve[k].end());
                for (int i:ve[k])
                    if (L[i]>=0)
                        dp[L[i]][j]=max(dp[L[i]][j],dp[i][j]-w[L[i]][j]*h[i][j]+a[L[i]][j]);
                reverse(ve[k].begin(),ve[k].end());
                for (int i:ve[k])
                    if (R[i]>=0)
                        dp[R[i]][j]=max(dp[R[i]][j],dp[i][j]-w[R[i]][j]*h[i][j]+a[R[i]][j]);
            }
        for (int i=0;i<n;i++)
            ve[l[i][j]].clear();
    }
    for (int i=0;i<n;i++)
        for (int j=0;j<n;j++)
            if (!F[i][j])
                ans=max(ans,dp[i][j]);
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 2 ms 16896 KB ok
4 Correct 2 ms 16988 KB ok
5 Correct 1 ms 10588 KB ok
6 Correct 2 ms 14684 KB ok
7 Correct 4 ms 21596 KB ok
8 Correct 34 ms 44372 KB ok
9 Correct 714 ms 147560 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 12636 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 1 ms 12632 KB ok
4 Correct 2 ms 12632 KB ok
5 Correct 2 ms 14680 KB ok
6 Correct 1 ms 12636 KB ok
7 Correct 2 ms 14684 KB ok
8 Correct 2 ms 14684 KB ok
9 Correct 2 ms 12636 KB ok
10 Correct 2 ms 12636 KB ok
11 Correct 2 ms 12636 KB ok
12 Correct 2 ms 12636 KB ok
13 Correct 2 ms 14856 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 2 ms 12636 KB ok
4 Correct 1 ms 12632 KB ok
5 Correct 2 ms 12632 KB ok
6 Correct 2 ms 14680 KB ok
7 Correct 1 ms 12636 KB ok
8 Correct 2 ms 14684 KB ok
9 Correct 2 ms 14684 KB ok
10 Correct 2 ms 12636 KB ok
11 Correct 2 ms 12636 KB ok
12 Correct 2 ms 12636 KB ok
13 Correct 2 ms 12636 KB ok
14 Correct 2 ms 14856 KB ok
15 Correct 2 ms 14684 KB ok
16 Correct 2 ms 14684 KB ok
17 Correct 2 ms 14684 KB ok
18 Correct 2 ms 14684 KB ok
19 Correct 2 ms 14684 KB ok
20 Correct 2 ms 12892 KB ok
21 Correct 2 ms 12632 KB ok
22 Correct 2 ms 12636 KB ok
23 Correct 2 ms 12636 KB ok
24 Correct 2 ms 12636 KB ok
25 Correct 2 ms 14684 KB ok
26 Correct 2 ms 14684 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 2 ms 12636 KB ok
4 Correct 2 ms 16896 KB ok
5 Correct 2 ms 16988 KB ok
6 Correct 1 ms 12632 KB ok
7 Correct 2 ms 12632 KB ok
8 Correct 2 ms 14680 KB ok
9 Correct 1 ms 12636 KB ok
10 Correct 2 ms 14684 KB ok
11 Correct 2 ms 14684 KB ok
12 Correct 2 ms 12636 KB ok
13 Correct 2 ms 12636 KB ok
14 Correct 2 ms 12636 KB ok
15 Correct 2 ms 12636 KB ok
16 Correct 2 ms 14856 KB ok
17 Correct 2 ms 14684 KB ok
18 Correct 2 ms 14684 KB ok
19 Correct 2 ms 14684 KB ok
20 Correct 2 ms 14684 KB ok
21 Correct 2 ms 14684 KB ok
22 Correct 2 ms 12892 KB ok
23 Correct 2 ms 12632 KB ok
24 Correct 2 ms 12636 KB ok
25 Correct 2 ms 12636 KB ok
26 Correct 2 ms 12636 KB ok
27 Correct 2 ms 14684 KB ok
28 Correct 2 ms 14684 KB ok
29 Correct 2 ms 14680 KB ok
30 Correct 2 ms 19032 KB ok
31 Correct 3 ms 19032 KB ok
32 Correct 2 ms 19036 KB ok
33 Correct 2 ms 19036 KB ok
34 Correct 2 ms 16984 KB ok
35 Correct 2 ms 16988 KB ok
36 Correct 2 ms 16988 KB ok
37 Correct 2 ms 16988 KB ok
38 Correct 2 ms 19036 KB ok
39 Correct 2 ms 16988 KB ok
40 Correct 2 ms 16888 KB ok
41 Correct 2 ms 19036 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 2 ms 12636 KB ok
4 Correct 2 ms 16896 KB ok
5 Correct 2 ms 16988 KB ok
6 Correct 1 ms 12632 KB ok
7 Correct 2 ms 12632 KB ok
8 Correct 2 ms 14680 KB ok
9 Correct 1 ms 12636 KB ok
10 Correct 2 ms 14684 KB ok
11 Correct 2 ms 14684 KB ok
12 Correct 2 ms 12636 KB ok
13 Correct 2 ms 12636 KB ok
14 Correct 2 ms 12636 KB ok
15 Correct 2 ms 12636 KB ok
16 Correct 2 ms 14856 KB ok
17 Correct 2 ms 14684 KB ok
18 Correct 2 ms 14684 KB ok
19 Correct 2 ms 14684 KB ok
20 Correct 2 ms 14684 KB ok
21 Correct 2 ms 14684 KB ok
22 Correct 2 ms 12892 KB ok
23 Correct 2 ms 12632 KB ok
24 Correct 2 ms 12636 KB ok
25 Correct 2 ms 12636 KB ok
26 Correct 2 ms 12636 KB ok
27 Correct 2 ms 14684 KB ok
28 Correct 2 ms 14684 KB ok
29 Correct 2 ms 14680 KB ok
30 Correct 2 ms 19032 KB ok
31 Correct 3 ms 19032 KB ok
32 Correct 2 ms 19036 KB ok
33 Correct 2 ms 19036 KB ok
34 Correct 2 ms 16984 KB ok
35 Correct 2 ms 16988 KB ok
36 Correct 2 ms 16988 KB ok
37 Correct 2 ms 16988 KB ok
38 Correct 2 ms 19036 KB ok
39 Correct 2 ms 16988 KB ok
40 Correct 2 ms 16888 KB ok
41 Correct 2 ms 19036 KB ok
42 Correct 44 ms 46536 KB ok
43 Correct 43 ms 46672 KB ok
44 Correct 40 ms 46420 KB ok
45 Correct 40 ms 46416 KB ok
46 Correct 40 ms 46676 KB ok
47 Correct 39 ms 46376 KB ok
48 Correct 39 ms 42840 KB ok
49 Correct 34 ms 42832 KB ok
50 Correct 36 ms 46668 KB ok
51 Correct 39 ms 46544 KB ok
52 Correct 33 ms 41820 KB ok
53 Correct 29 ms 41040 KB ok
54 Correct 29 ms 41552 KB ok
55 Correct 32 ms 44592 KB ok
56 Correct 31 ms 40276 KB ok
57 Correct 36 ms 45148 KB ok
58 Correct 40 ms 45364 KB ok
59 Correct 38 ms 45264 KB ok
# Verdict Execution time Memory Grader output
1 Correct 2 ms 14684 KB ok
2 Correct 2 ms 12636 KB ok
3 Correct 2 ms 12636 KB ok
4 Correct 2 ms 16896 KB ok
5 Correct 2 ms 16988 KB ok
6 Correct 1 ms 10588 KB ok
7 Correct 2 ms 14684 KB ok
8 Correct 4 ms 21596 KB ok
9 Correct 34 ms 44372 KB ok
10 Correct 714 ms 147560 KB ok
11 Correct 1 ms 12632 KB ok
12 Correct 2 ms 12632 KB ok
13 Correct 2 ms 14680 KB ok
14 Correct 1 ms 12636 KB ok
15 Correct 2 ms 14684 KB ok
16 Correct 2 ms 14684 KB ok
17 Correct 2 ms 12636 KB ok
18 Correct 2 ms 12636 KB ok
19 Correct 2 ms 12636 KB ok
20 Correct 2 ms 12636 KB ok
21 Correct 2 ms 14856 KB ok
22 Correct 2 ms 14684 KB ok
23 Correct 2 ms 14684 KB ok
24 Correct 2 ms 14684 KB ok
25 Correct 2 ms 14684 KB ok
26 Correct 2 ms 14684 KB ok
27 Correct 2 ms 12892 KB ok
28 Correct 2 ms 12632 KB ok
29 Correct 2 ms 12636 KB ok
30 Correct 2 ms 12636 KB ok
31 Correct 2 ms 12636 KB ok
32 Correct 2 ms 14684 KB ok
33 Correct 2 ms 14684 KB ok
34 Correct 2 ms 14680 KB ok
35 Correct 2 ms 19032 KB ok
36 Correct 3 ms 19032 KB ok
37 Correct 2 ms 19036 KB ok
38 Correct 2 ms 19036 KB ok
39 Correct 2 ms 16984 KB ok
40 Correct 2 ms 16988 KB ok
41 Correct 2 ms 16988 KB ok
42 Correct 2 ms 16988 KB ok
43 Correct 2 ms 19036 KB ok
44 Correct 2 ms 16988 KB ok
45 Correct 2 ms 16888 KB ok
46 Correct 2 ms 19036 KB ok
47 Correct 44 ms 46536 KB ok
48 Correct 43 ms 46672 KB ok
49 Correct 40 ms 46420 KB ok
50 Correct 40 ms 46416 KB ok
51 Correct 40 ms 46676 KB ok
52 Correct 39 ms 46376 KB ok
53 Correct 39 ms 42840 KB ok
54 Correct 34 ms 42832 KB ok
55 Correct 36 ms 46668 KB ok
56 Correct 39 ms 46544 KB ok
57 Correct 33 ms 41820 KB ok
58 Correct 29 ms 41040 KB ok
59 Correct 29 ms 41552 KB ok
60 Correct 32 ms 44592 KB ok
61 Correct 31 ms 40276 KB ok
62 Correct 36 ms 45148 KB ok
63 Correct 40 ms 45364 KB ok
64 Correct 38 ms 45264 KB ok
65 Correct 707 ms 159900 KB ok
66 Correct 567 ms 161872 KB ok
67 Correct 495 ms 159824 KB ok
68 Correct 776 ms 158032 KB ok
69 Correct 703 ms 158448 KB ok
70 Correct 726 ms 158288 KB ok
71 Correct 799 ms 157780 KB ok
72 Correct 752 ms 157792 KB ok
73 Correct 609 ms 157264 KB ok
74 Correct 572 ms 157264 KB ok
75 Correct 579 ms 157268 KB ok
76 Correct 634 ms 161876 KB ok
77 Correct 657 ms 161872 KB ok
78 Correct 665 ms 158804 KB ok
79 Correct 501 ms 158288 KB ok
80 Correct 503 ms 158032 KB ok
81 Correct 514 ms 158012 KB ok
82 Correct 555 ms 158036 KB ok
83 Correct 531 ms 159556 KB ok
84 Correct 531 ms 148048 KB ok
85 Correct 475 ms 146372 KB ok
86 Correct 504 ms 149092 KB ok
87 Correct 491 ms 150092 KB ok
88 Correct 550 ms 145640 KB ok
89 Correct 718 ms 156880 KB ok
90 Correct 649 ms 157264 KB ok
91 Correct 647 ms 156496 KB ok
92 Correct 500 ms 158700 KB ok
93 Correct 511 ms 159312 KB ok
94 Correct 537 ms 158180 KB ok
95 Correct 511 ms 158064 KB ok
96 Correct 505 ms 158028 KB ok
97 Correct 517 ms 157776 KB ok
98 Correct 503 ms 157268 KB ok
99 Correct 645 ms 158568 KB ok
100 Correct 698 ms 156496 KB ok
101 Correct 678 ms 157776 KB ok
102 Correct 667 ms 157780 KB ok
103 Correct 686 ms 156492 KB ok
104 Correct 681 ms 157984 KB ok
105 Correct 709 ms 157984 KB ok
106 Correct 665 ms 156756 KB ok
107 Correct 674 ms 156872 KB ok
108 Correct 671 ms 160596 KB ok
109 Correct 742 ms 160848 KB ok