// hola soy Dember :D
// 31/03/2024
#include <bits/stdc++.h>
#define ll int
#define pll pair<ll,ll>
#define F first
#define S second
#define Z size()
#define pb push_back
#define bp pop_back
#define fo(x,y,z) for(ll x=y; x<=z; x++)
#define of(x,y,z) for(ll x=y; x>=z; x--)
#define all(n) n.begin(), n.end()
#define arr(x,y,z) x+y, x+y+z
using namespace std;
ll n;
ll ans=0;
vector<vector<ll>> iz, A, res;
vector<ll> dp, tt, xd, zd;
vector<pll> r;
vector<ll> cl(ll p){
vector<ll> st, v(n+1);
ll x;
fo(i,0,n)v[i]=i;
fo(i,0,n-1){
x=i;
while(!st.empty() && iz[st.back()][p]<=iz[i][p]){x=st.back();st.pop_back();}
st.push_back(i);
v[i]=v[x];
}
return v;
}
vector<ll> cr(ll p){
vector<ll> st, v(n+1);
ll x;
fo(i,0,n)v[i]=i;
of(i,n-1,0){
x=i;
while(!st.empty() && iz[st.back()][p]<=iz[i][p]){x=st.back();st.pop_back();}
st.push_back(i);
v[i]=v[x];
}
return v;
}
void CD(ll p){
vector<ll> a, b, c(n+1), d;r.clear();
a=cl(p);
b=cr(p);
fo(i,0,n-1)c[i]=b[i]-a[i]+1;
xd.resize(n+1,-1);
zd.resize(n+1,-1);
fo(i,0,n-1){
if(!A[i][p])r.pb({iz[i][p], i});
xd[i]=i-1;zd[i]=i+1;
}zd[n-1]=-1;
sort(all(r));
for(auto u:r)dp[u.S]+=(c[u.S]-tt[u.S])*(p-iz[u.S][p]);
for(auto u:r){
if(zd[u.S]>=0)dp[zd[u.S]]=max(dp[zd[u.S]],(c[zd[u.S]]-c[u.S])*(p-iz[zd[u.S]][p])+dp[u.S]);
if(xd[u.S]>=0)dp[xd[u.S]]=max(dp[xd[u.S]],(c[xd[u.S]]-c[u.S])*(p-iz[xd[u.S]][p])+dp[u.S]);
if(zd[u.S]!=-1)xd[zd[u.S]]=xd[u.S];
if(xd[u.S]!=-1)zd[xd[u.S]]=zd[u.S];
tt[u.S]=c[u.S];
}
//for(auto u:c)cout<<u<<' ';cout<<"\n";
res.pb(dp);
fo(i,0,n-1) if(A[i][p])dp[i]=tt[i]=0;
//fo(i,0,n)cout<<tt[i]<<' ';cout<<"\n";
return;
}
int biggest_stadium(int N, vector<vector<int>> ola){
n=N;iz.resize(n+1,vector<ll>(n+1,-1));A=ola;dp.resize(n+1,0);tt.resize(n+1,0);
fo(i,0,n-1){
fo(j,0,n-1){
if(A[i][j])iz[i][j]=j;
else if(j>0)iz[i][j]=iz[i][j-1];
}
}
of(h,n-1,0)CD(h);
for(auto u:res)
for(auto w:u)ans=max(w,ans);
return ans;
}
/*int main()
{
cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
int t=1;
cin>>t;
vector<vector<int>> ola(t+1,vector<int> (t+1));
fo(i,0,t-1)
fo(j,0,t-1)cin>>ola[i][j];
cout<<biggest_stadium(t, ola)<<"\n";
fo(i,0,n-1){
fo(j,0,n-1)cout<<res[i][j]<<' ';cout<<"\n";
}
return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
ok |
# |
Verdict |
Execution time |
Memory |
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 |
1 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
604 KB |
ok |
8 |
Correct |
26 ms |
5244 KB |
ok |
9 |
Correct |
539 ms |
79084 KB |
ok |
# |
Verdict |
Execution time |
Memory |
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 |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
344 KB |
ok |
12 |
Correct |
1 ms |
544 KB |
ok |
13 |
Correct |
1 ms |
756 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
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 |
344 KB |
ok |
13 |
Correct |
1 ms |
544 KB |
ok |
14 |
Correct |
1 ms |
756 KB |
ok |
15 |
Correct |
0 ms |
344 KB |
ok |
16 |
Correct |
1 ms |
344 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
1 ms |
348 KB |
ok |
19 |
Correct |
0 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 |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
1 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
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 |
1 ms |
544 KB |
ok |
16 |
Correct |
1 ms |
756 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
1 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
1 ms |
348 KB |
ok |
29 |
Correct |
1 ms |
348 KB |
ok |
30 |
Correct |
0 ms |
348 KB |
ok |
31 |
Correct |
0 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
344 KB |
ok |
33 |
Correct |
0 ms |
348 KB |
ok |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Correct |
0 ms |
348 KB |
ok |
37 |
Correct |
0 ms |
348 KB |
ok |
38 |
Correct |
1 ms |
348 KB |
ok |
39 |
Correct |
1 ms |
348 KB |
ok |
40 |
Correct |
0 ms |
440 KB |
ok |
41 |
Correct |
0 ms |
348 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
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 |
1 ms |
544 KB |
ok |
16 |
Correct |
1 ms |
756 KB |
ok |
17 |
Correct |
0 ms |
344 KB |
ok |
18 |
Correct |
1 ms |
344 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
344 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
0 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
0 ms |
348 KB |
ok |
28 |
Correct |
1 ms |
348 KB |
ok |
29 |
Correct |
1 ms |
348 KB |
ok |
30 |
Correct |
0 ms |
348 KB |
ok |
31 |
Correct |
0 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
344 KB |
ok |
33 |
Correct |
0 ms |
348 KB |
ok |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
348 KB |
ok |
36 |
Correct |
0 ms |
348 KB |
ok |
37 |
Correct |
0 ms |
348 KB |
ok |
38 |
Correct |
1 ms |
348 KB |
ok |
39 |
Correct |
1 ms |
348 KB |
ok |
40 |
Correct |
0 ms |
440 KB |
ok |
41 |
Correct |
0 ms |
348 KB |
ok |
42 |
Correct |
40 ms |
5200 KB |
ok |
43 |
Correct |
38 ms |
5268 KB |
ok |
44 |
Correct |
38 ms |
5244 KB |
ok |
45 |
Correct |
44 ms |
5204 KB |
ok |
46 |
Correct |
40 ms |
5204 KB |
ok |
47 |
Correct |
30 ms |
5212 KB |
ok |
48 |
Correct |
26 ms |
5344 KB |
ok |
49 |
Correct |
25 ms |
5280 KB |
ok |
50 |
Correct |
25 ms |
5212 KB |
ok |
51 |
Correct |
31 ms |
5208 KB |
ok |
52 |
Correct |
21 ms |
5208 KB |
ok |
53 |
Correct |
20 ms |
5212 KB |
ok |
54 |
Correct |
23 ms |
5204 KB |
ok |
55 |
Correct |
24 ms |
5260 KB |
ok |
56 |
Correct |
22 ms |
5208 KB |
ok |
57 |
Correct |
27 ms |
5184 KB |
ok |
58 |
Correct |
27 ms |
5200 KB |
ok |
59 |
Correct |
29 ms |
5400 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
1 ms |
604 KB |
ok |
9 |
Correct |
26 ms |
5244 KB |
ok |
10 |
Correct |
539 ms |
79084 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 |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
344 KB |
ok |
20 |
Correct |
1 ms |
544 KB |
ok |
21 |
Correct |
1 ms |
756 KB |
ok |
22 |
Correct |
0 ms |
344 KB |
ok |
23 |
Correct |
1 ms |
344 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 |
1 ms |
348 KB |
ok |
28 |
Correct |
0 ms |
344 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
0 ms |
348 KB |
ok |
31 |
Correct |
0 ms |
348 KB |
ok |
32 |
Correct |
0 ms |
348 KB |
ok |
33 |
Correct |
1 ms |
348 KB |
ok |
34 |
Correct |
1 ms |
348 KB |
ok |
35 |
Correct |
0 ms |
348 KB |
ok |
36 |
Correct |
0 ms |
348 KB |
ok |
37 |
Correct |
0 ms |
344 KB |
ok |
38 |
Correct |
0 ms |
348 KB |
ok |
39 |
Correct |
1 ms |
348 KB |
ok |
40 |
Correct |
1 ms |
348 KB |
ok |
41 |
Correct |
0 ms |
348 KB |
ok |
42 |
Correct |
0 ms |
348 KB |
ok |
43 |
Correct |
1 ms |
348 KB |
ok |
44 |
Correct |
1 ms |
348 KB |
ok |
45 |
Correct |
0 ms |
440 KB |
ok |
46 |
Correct |
0 ms |
348 KB |
ok |
47 |
Correct |
40 ms |
5200 KB |
ok |
48 |
Correct |
38 ms |
5268 KB |
ok |
49 |
Correct |
38 ms |
5244 KB |
ok |
50 |
Correct |
44 ms |
5204 KB |
ok |
51 |
Correct |
40 ms |
5204 KB |
ok |
52 |
Correct |
30 ms |
5212 KB |
ok |
53 |
Correct |
26 ms |
5344 KB |
ok |
54 |
Correct |
25 ms |
5280 KB |
ok |
55 |
Correct |
25 ms |
5212 KB |
ok |
56 |
Correct |
31 ms |
5208 KB |
ok |
57 |
Correct |
21 ms |
5208 KB |
ok |
58 |
Correct |
20 ms |
5212 KB |
ok |
59 |
Correct |
23 ms |
5204 KB |
ok |
60 |
Correct |
24 ms |
5260 KB |
ok |
61 |
Correct |
22 ms |
5208 KB |
ok |
62 |
Correct |
27 ms |
5184 KB |
ok |
63 |
Correct |
27 ms |
5200 KB |
ok |
64 |
Correct |
29 ms |
5400 KB |
ok |
65 |
Correct |
800 ms |
87280 KB |
ok |
66 |
Correct |
556 ms |
87004 KB |
ok |
67 |
Correct |
474 ms |
86928 KB |
ok |
68 |
Correct |
788 ms |
86928 KB |
ok |
69 |
Correct |
854 ms |
86796 KB |
ok |
70 |
Correct |
895 ms |
86828 KB |
ok |
71 |
Correct |
797 ms |
86968 KB |
ok |
72 |
Correct |
725 ms |
86980 KB |
ok |
73 |
Correct |
589 ms |
86864 KB |
ok |
74 |
Correct |
596 ms |
86868 KB |
ok |
75 |
Correct |
582 ms |
86864 KB |
ok |
76 |
Correct |
623 ms |
86868 KB |
ok |
77 |
Correct |
612 ms |
86832 KB |
ok |
78 |
Correct |
713 ms |
86868 KB |
ok |
79 |
Correct |
465 ms |
86868 KB |
ok |
80 |
Correct |
449 ms |
86864 KB |
ok |
81 |
Correct |
463 ms |
86868 KB |
ok |
82 |
Correct |
514 ms |
86964 KB |
ok |
83 |
Correct |
507 ms |
86864 KB |
ok |
84 |
Correct |
445 ms |
87128 KB |
ok |
85 |
Correct |
433 ms |
86868 KB |
ok |
86 |
Correct |
445 ms |
86940 KB |
ok |
87 |
Correct |
452 ms |
86868 KB |
ok |
88 |
Correct |
464 ms |
86884 KB |
ok |
89 |
Correct |
595 ms |
86932 KB |
ok |
90 |
Correct |
572 ms |
86868 KB |
ok |
91 |
Correct |
639 ms |
86868 KB |
ok |
92 |
Correct |
472 ms |
87056 KB |
ok |
93 |
Correct |
461 ms |
86864 KB |
ok |
94 |
Correct |
458 ms |
86868 KB |
ok |
95 |
Correct |
449 ms |
86864 KB |
ok |
96 |
Correct |
450 ms |
86920 KB |
ok |
97 |
Correct |
481 ms |
87060 KB |
ok |
98 |
Correct |
450 ms |
86956 KB |
ok |
99 |
Correct |
715 ms |
87120 KB |
ok |
100 |
Correct |
585 ms |
87204 KB |
ok |
101 |
Correct |
594 ms |
87204 KB |
ok |
102 |
Correct |
604 ms |
87152 KB |
ok |
103 |
Correct |
621 ms |
87124 KB |
ok |
104 |
Correct |
639 ms |
87132 KB |
ok |
105 |
Correct |
656 ms |
86800 KB |
ok |
106 |
Correct |
617 ms |
86864 KB |
ok |
107 |
Correct |
601 ms |
86800 KB |
ok |
108 |
Correct |
616 ms |
86920 KB |
ok |
109 |
Correct |
846 ms |
79184 KB |
ok |