#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
#define mp make_pair
#define fr first
#define sc second
int n,ht[2069],lg2[2069],dp[8000069],dsu[8000069],z=0;
bitset<2069> a[2069];
pair<pair<int,int>,pair<int,int>> ky[8000069];
pair<int,int> sp[2][2069][6][2069];
vector<int> al[8000069];
bitset<8000069> vtd;
inline int god(int xx,int x,int y)
{
return xx*n*n+(x-1)*n+y;
}
inline void spbd(int xx,int x)
{
int i,j;
for(i=1;i<=n;i++)
{
sp[xx][x][0][i]={ht[i],i};
}
for(i=1;1<<i*2<=n;i++)
{
for(j=1;j<=n-(1<<i*2)+1;j++)
{
sp[xx][x][i][j]=min({sp[xx][x][i-1][j],sp[xx][x][i-1][j+(1<<(i-1)*2)],sp[xx][x][i-1][j+(1<<(i-1)*2)*2],sp[xx][x][i-1][j+(1<<(i-1)*2)*3]});
}
}
}
inline pair<int,int> spqr(int xx,int x,int lb,int rb)
{
int e=lg2[rb-lb+1];
return min({sp[xx][x][e][lb],sp[xx][x][e][min(lb+(1<<e*2),rb-(1<<e*2)+1)],sp[xx][x][e][min(lb+(1<<e*2)*2,rb-(1<<e*2)+1)],sp[xx][x][e][rb-(1<<e*2)+1]});
}
inline void ae(int x,int y)
{
al[x].push_back(y);
}
int fd(int x)
{
if(dsu[x]!=x)
{
dsu[x]=fd(dsu[x]);
}
return dsu[x];
}
inline int dnc(int xx,int x,int lb,int rb)
{
if(lb<=rb)
{
int u,k,l,p,p2,e,clb,crb;
pair<int,int> tmp=spqr(xx,x,lb,rb),tmp2;
u=!xx*2-1;
clb=x-(tmp.fr-1)*u;
crb=x;
if(xx)
{
swap(clb,crb);
}
if(clb<=crb)
{
p=god(xx,x,tmp.sc);
ky[p]={{clb,crb},{lb,rb}};
}
else
{
p=-1;
}
for(k=lb,l=rb;k<=l;k=e+1)
{
tmp2=spqr(xx,x,k,l);
if(tmp2.fr!=tmp.fr)
{
break;
}
e=tmp2.sc;
p2=dnc(xx,x,k,e-1);
if(p!=-1&&p2!=-1)
{
ae(p,p2);
}
}
p2=dnc(xx,x,k,l);
if(p!=-1&&p2!=-1)
{
ae(p,p2);
}
if(p!=-1)
{
tmp2=spqr(!xx,x-(tmp.fr-1)*u,lb,rb);
p2=god(!xx,x-(tmp.fr-1)*u,tmp2.sc);
if(tmp2.fr!=tmp.fr)
{
ae(p,p2);
}
else
{
dsu[fd(p2)]=fd(p);
}
}
return p;
}
else
{
return -1;
}
}
void dfs(int x)
{
int i,sz=al[x].size(),l,w,clb,crb,lb,rb,lb2,rb2;
vtd[x]=1;
dp[x]=0;
for(i=0;i<sz;i++)
{
l=fd(al[x][i]);
clb=ky[x].fr.fr;
crb=ky[x].fr.sc;
lb=ky[l].fr.fr;
rb=ky[l].fr.sc;
lb2=ky[l].sc.fr;
rb2=ky[l].sc.sc;
w=(rb-lb-(crb-clb))*(rb2-lb2+1);
if(!vtd[l])
{
dfs(l);
}
dp[x]=max(dp[x],dp[l]+w);
}
lb=ky[x].fr.fr;
rb=ky[x].fr.sc;
lb2=ky[x].sc.fr;
rb2=ky[x].sc.sc;
z=max(z,dp[x]+(rb-lb+1)*(rb2-lb2+1));
}
int biggest_stadium(int on,vector<vector<int>> oa)
{
int i,j,ii,u,k,l,sz;
n=on;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
a[i][j]=oa[i-1][j-1];
}
for(k=i;k;k/=4,lg2[i]++);
lg2[i]--;
}
for(ii=0;ii<2;ii++)
{
u=!ii*2-1;
for(i=1;i<=n;i++)
{
ht[i]=0;
}
for(i=1+(n-1)*ii;i&&i<=n;i+=u)
{
for(j=1;j<=n;j++)
{
ht[j]=(ht[j]+1)*!a[i][j];
}
spbd(ii,i);
}
}
for(i=1;i<=n*n*2;i++)
{
dsu[i]=i;
}
for(ii=0;ii<2;ii++)
{
u=!ii*2-1;
for(i=1+(n-1)*ii;i&&i<=n;i+=u)
{
dnc(ii,i,1,n);
}
}
for(i=1;i<=n*n*2;i++)
{
if(fd(i)!=i)
{
sz=al[i].size();
for(j=0;j<sz;j++)
{
l=al[i][j];
al[fd(i)].push_back(l);
}
}
}
for(i=1;i<=n*n*2;i++)
{
if(ky[i].fr.fr&&!vtd[i])
{
dfs(i);
}
}
return z;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
189032 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
189012 KB |
ok |
2 |
Correct |
56 ms |
189088 KB |
ok |
3 |
Correct |
68 ms |
189268 KB |
ok |
4 |
Correct |
56 ms |
189264 KB |
ok |
5 |
Correct |
55 ms |
189008 KB |
ok |
6 |
Correct |
58 ms |
189008 KB |
ok |
7 |
Correct |
59 ms |
193332 KB |
ok |
8 |
Correct |
105 ms |
239436 KB |
ok |
9 |
Correct |
850 ms |
673552 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
69 ms |
189012 KB |
ok |
2 |
Correct |
56 ms |
189088 KB |
ok |
3 |
Correct |
68 ms |
188988 KB |
ok |
4 |
Correct |
62 ms |
189132 KB |
ok |
5 |
Correct |
56 ms |
188960 KB |
ok |
6 |
Correct |
63 ms |
189012 KB |
ok |
7 |
Correct |
70 ms |
189012 KB |
ok |
8 |
Correct |
56 ms |
189012 KB |
ok |
9 |
Correct |
61 ms |
189092 KB |
ok |
10 |
Correct |
57 ms |
189012 KB |
ok |
11 |
Correct |
59 ms |
195212 KB |
ok |
12 |
Correct |
47 ms |
189164 KB |
ok |
13 |
Correct |
43 ms |
201308 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
189032 KB |
ok |
2 |
Correct |
69 ms |
189012 KB |
ok |
3 |
Correct |
56 ms |
189088 KB |
ok |
4 |
Correct |
68 ms |
188988 KB |
ok |
5 |
Correct |
62 ms |
189132 KB |
ok |
6 |
Correct |
56 ms |
188960 KB |
ok |
7 |
Correct |
63 ms |
189012 KB |
ok |
8 |
Correct |
70 ms |
189012 KB |
ok |
9 |
Correct |
56 ms |
189012 KB |
ok |
10 |
Correct |
61 ms |
189092 KB |
ok |
11 |
Correct |
57 ms |
189012 KB |
ok |
12 |
Correct |
59 ms |
195212 KB |
ok |
13 |
Correct |
47 ms |
189164 KB |
ok |
14 |
Correct |
43 ms |
201308 KB |
ok |
15 |
Correct |
44 ms |
201592 KB |
ok |
16 |
Correct |
41 ms |
201300 KB |
ok |
17 |
Correct |
44 ms |
201300 KB |
ok |
18 |
Correct |
42 ms |
201300 KB |
ok |
19 |
Correct |
41 ms |
201312 KB |
ok |
20 |
Correct |
41 ms |
201300 KB |
ok |
21 |
Correct |
41 ms |
201296 KB |
ok |
22 |
Correct |
41 ms |
201560 KB |
ok |
23 |
Correct |
41 ms |
201564 KB |
ok |
24 |
Correct |
40 ms |
201308 KB |
ok |
25 |
Correct |
41 ms |
201332 KB |
ok |
26 |
Correct |
41 ms |
201296 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
189032 KB |
ok |
2 |
Correct |
69 ms |
189012 KB |
ok |
3 |
Correct |
56 ms |
189088 KB |
ok |
4 |
Correct |
68 ms |
189268 KB |
ok |
5 |
Correct |
56 ms |
189264 KB |
ok |
6 |
Correct |
68 ms |
188988 KB |
ok |
7 |
Correct |
62 ms |
189132 KB |
ok |
8 |
Correct |
56 ms |
188960 KB |
ok |
9 |
Correct |
63 ms |
189012 KB |
ok |
10 |
Correct |
70 ms |
189012 KB |
ok |
11 |
Correct |
56 ms |
189012 KB |
ok |
12 |
Correct |
61 ms |
189092 KB |
ok |
13 |
Correct |
57 ms |
189012 KB |
ok |
14 |
Correct |
59 ms |
195212 KB |
ok |
15 |
Correct |
47 ms |
189164 KB |
ok |
16 |
Correct |
43 ms |
201308 KB |
ok |
17 |
Correct |
44 ms |
201592 KB |
ok |
18 |
Correct |
41 ms |
201300 KB |
ok |
19 |
Correct |
44 ms |
201300 KB |
ok |
20 |
Correct |
42 ms |
201300 KB |
ok |
21 |
Correct |
41 ms |
201312 KB |
ok |
22 |
Correct |
41 ms |
201300 KB |
ok |
23 |
Correct |
41 ms |
201296 KB |
ok |
24 |
Correct |
41 ms |
201560 KB |
ok |
25 |
Correct |
41 ms |
201564 KB |
ok |
26 |
Correct |
40 ms |
201308 KB |
ok |
27 |
Correct |
41 ms |
201332 KB |
ok |
28 |
Correct |
41 ms |
201296 KB |
ok |
29 |
Correct |
40 ms |
201304 KB |
ok |
30 |
Correct |
42 ms |
205656 KB |
ok |
31 |
Correct |
41 ms |
205568 KB |
ok |
32 |
Correct |
41 ms |
205648 KB |
ok |
33 |
Correct |
42 ms |
205648 KB |
ok |
34 |
Correct |
42 ms |
205660 KB |
ok |
35 |
Correct |
41 ms |
205660 KB |
ok |
36 |
Correct |
41 ms |
205652 KB |
ok |
37 |
Correct |
42 ms |
205612 KB |
ok |
38 |
Correct |
42 ms |
205648 KB |
ok |
39 |
Correct |
41 ms |
205648 KB |
ok |
40 |
Correct |
42 ms |
205652 KB |
ok |
41 |
Correct |
41 ms |
205656 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
189032 KB |
ok |
2 |
Correct |
69 ms |
189012 KB |
ok |
3 |
Correct |
56 ms |
189088 KB |
ok |
4 |
Correct |
68 ms |
189268 KB |
ok |
5 |
Correct |
56 ms |
189264 KB |
ok |
6 |
Correct |
68 ms |
188988 KB |
ok |
7 |
Correct |
62 ms |
189132 KB |
ok |
8 |
Correct |
56 ms |
188960 KB |
ok |
9 |
Correct |
63 ms |
189012 KB |
ok |
10 |
Correct |
70 ms |
189012 KB |
ok |
11 |
Correct |
56 ms |
189012 KB |
ok |
12 |
Correct |
61 ms |
189092 KB |
ok |
13 |
Correct |
57 ms |
189012 KB |
ok |
14 |
Correct |
59 ms |
195212 KB |
ok |
15 |
Correct |
47 ms |
189164 KB |
ok |
16 |
Correct |
43 ms |
201308 KB |
ok |
17 |
Correct |
44 ms |
201592 KB |
ok |
18 |
Correct |
41 ms |
201300 KB |
ok |
19 |
Correct |
44 ms |
201300 KB |
ok |
20 |
Correct |
42 ms |
201300 KB |
ok |
21 |
Correct |
41 ms |
201312 KB |
ok |
22 |
Correct |
41 ms |
201300 KB |
ok |
23 |
Correct |
41 ms |
201296 KB |
ok |
24 |
Correct |
41 ms |
201560 KB |
ok |
25 |
Correct |
41 ms |
201564 KB |
ok |
26 |
Correct |
40 ms |
201308 KB |
ok |
27 |
Correct |
41 ms |
201332 KB |
ok |
28 |
Correct |
41 ms |
201296 KB |
ok |
29 |
Correct |
40 ms |
201304 KB |
ok |
30 |
Correct |
42 ms |
205656 KB |
ok |
31 |
Correct |
41 ms |
205568 KB |
ok |
32 |
Correct |
41 ms |
205648 KB |
ok |
33 |
Correct |
42 ms |
205648 KB |
ok |
34 |
Correct |
42 ms |
205660 KB |
ok |
35 |
Correct |
41 ms |
205660 KB |
ok |
36 |
Correct |
41 ms |
205652 KB |
ok |
37 |
Correct |
42 ms |
205612 KB |
ok |
38 |
Correct |
42 ms |
205648 KB |
ok |
39 |
Correct |
41 ms |
205648 KB |
ok |
40 |
Correct |
42 ms |
205652 KB |
ok |
41 |
Correct |
41 ms |
205656 KB |
ok |
42 |
Correct |
167 ms |
313940 KB |
ok |
43 |
Correct |
167 ms |
311520 KB |
ok |
44 |
Correct |
161 ms |
315656 KB |
ok |
45 |
Correct |
150 ms |
314400 KB |
ok |
46 |
Correct |
173 ms |
315400 KB |
ok |
47 |
Correct |
94 ms |
303956 KB |
ok |
48 |
Correct |
98 ms |
312920 KB |
ok |
49 |
Correct |
105 ms |
310576 KB |
ok |
50 |
Correct |
114 ms |
319060 KB |
ok |
51 |
Correct |
118 ms |
317416 KB |
ok |
52 |
Correct |
91 ms |
309548 KB |
ok |
53 |
Correct |
88 ms |
304324 KB |
ok |
54 |
Correct |
90 ms |
311380 KB |
ok |
55 |
Correct |
95 ms |
312280 KB |
ok |
56 |
Correct |
88 ms |
308832 KB |
ok |
57 |
Correct |
124 ms |
318032 KB |
ok |
58 |
Correct |
113 ms |
318700 KB |
ok |
59 |
Correct |
139 ms |
319516 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
56 ms |
189032 KB |
ok |
2 |
Correct |
69 ms |
189012 KB |
ok |
3 |
Correct |
56 ms |
189088 KB |
ok |
4 |
Correct |
68 ms |
189268 KB |
ok |
5 |
Correct |
56 ms |
189264 KB |
ok |
6 |
Correct |
55 ms |
189008 KB |
ok |
7 |
Correct |
58 ms |
189008 KB |
ok |
8 |
Correct |
59 ms |
193332 KB |
ok |
9 |
Correct |
105 ms |
239436 KB |
ok |
10 |
Correct |
850 ms |
673552 KB |
ok |
11 |
Correct |
68 ms |
188988 KB |
ok |
12 |
Correct |
62 ms |
189132 KB |
ok |
13 |
Correct |
56 ms |
188960 KB |
ok |
14 |
Correct |
63 ms |
189012 KB |
ok |
15 |
Correct |
70 ms |
189012 KB |
ok |
16 |
Correct |
56 ms |
189012 KB |
ok |
17 |
Correct |
61 ms |
189092 KB |
ok |
18 |
Correct |
57 ms |
189012 KB |
ok |
19 |
Correct |
59 ms |
195212 KB |
ok |
20 |
Correct |
47 ms |
189164 KB |
ok |
21 |
Correct |
43 ms |
201308 KB |
ok |
22 |
Correct |
44 ms |
201592 KB |
ok |
23 |
Correct |
41 ms |
201300 KB |
ok |
24 |
Correct |
44 ms |
201300 KB |
ok |
25 |
Correct |
42 ms |
201300 KB |
ok |
26 |
Correct |
41 ms |
201312 KB |
ok |
27 |
Correct |
41 ms |
201300 KB |
ok |
28 |
Correct |
41 ms |
201296 KB |
ok |
29 |
Correct |
41 ms |
201560 KB |
ok |
30 |
Correct |
41 ms |
201564 KB |
ok |
31 |
Correct |
40 ms |
201308 KB |
ok |
32 |
Correct |
41 ms |
201332 KB |
ok |
33 |
Correct |
41 ms |
201296 KB |
ok |
34 |
Correct |
40 ms |
201304 KB |
ok |
35 |
Correct |
42 ms |
205656 KB |
ok |
36 |
Correct |
41 ms |
205568 KB |
ok |
37 |
Correct |
41 ms |
205648 KB |
ok |
38 |
Correct |
42 ms |
205648 KB |
ok |
39 |
Correct |
42 ms |
205660 KB |
ok |
40 |
Correct |
41 ms |
205660 KB |
ok |
41 |
Correct |
41 ms |
205652 KB |
ok |
42 |
Correct |
42 ms |
205612 KB |
ok |
43 |
Correct |
42 ms |
205648 KB |
ok |
44 |
Correct |
41 ms |
205648 KB |
ok |
45 |
Correct |
42 ms |
205652 KB |
ok |
46 |
Correct |
41 ms |
205656 KB |
ok |
47 |
Correct |
167 ms |
313940 KB |
ok |
48 |
Correct |
167 ms |
311520 KB |
ok |
49 |
Correct |
161 ms |
315656 KB |
ok |
50 |
Correct |
150 ms |
314400 KB |
ok |
51 |
Correct |
173 ms |
315400 KB |
ok |
52 |
Correct |
94 ms |
303956 KB |
ok |
53 |
Correct |
98 ms |
312920 KB |
ok |
54 |
Correct |
105 ms |
310576 KB |
ok |
55 |
Correct |
114 ms |
319060 KB |
ok |
56 |
Correct |
118 ms |
317416 KB |
ok |
57 |
Correct |
91 ms |
309548 KB |
ok |
58 |
Correct |
88 ms |
304324 KB |
ok |
59 |
Correct |
90 ms |
311380 KB |
ok |
60 |
Correct |
95 ms |
312280 KB |
ok |
61 |
Correct |
88 ms |
308832 KB |
ok |
62 |
Correct |
124 ms |
318032 KB |
ok |
63 |
Correct |
113 ms |
318700 KB |
ok |
64 |
Correct |
139 ms |
319516 KB |
ok |
65 |
Correct |
2233 ms |
984980 KB |
ok |
66 |
Correct |
1053 ms |
823948 KB |
ok |
67 |
Correct |
901 ms |
801980 KB |
ok |
68 |
Correct |
1903 ms |
984412 KB |
ok |
69 |
Correct |
2174 ms |
1037972 KB |
ok |
70 |
Correct |
2228 ms |
1037452 KB |
ok |
71 |
Correct |
1500 ms |
952680 KB |
ok |
72 |
Correct |
771 ms |
813124 KB |
ok |
73 |
Correct |
952 ms |
841296 KB |
ok |
74 |
Correct |
911 ms |
849540 KB |
ok |
75 |
Correct |
923 ms |
851000 KB |
ok |
76 |
Correct |
1043 ms |
950180 KB |
ok |
77 |
Correct |
1067 ms |
950580 KB |
ok |
78 |
Correct |
1231 ms |
919580 KB |
ok |
79 |
Correct |
839 ms |
816780 KB |
ok |
80 |
Correct |
791 ms |
816580 KB |
ok |
81 |
Correct |
864 ms |
825172 KB |
ok |
82 |
Correct |
998 ms |
847876 KB |
ok |
83 |
Correct |
1057 ms |
840028 KB |
ok |
84 |
Correct |
720 ms |
718728 KB |
ok |
85 |
Correct |
672 ms |
693720 KB |
ok |
86 |
Correct |
740 ms |
736592 KB |
ok |
87 |
Correct |
737 ms |
746528 KB |
ok |
88 |
Correct |
709 ms |
745924 KB |
ok |
89 |
Correct |
689 ms |
798920 KB |
ok |
90 |
Correct |
696 ms |
808160 KB |
ok |
91 |
Correct |
716 ms |
808708 KB |
ok |
92 |
Correct |
850 ms |
816148 KB |
ok |
93 |
Correct |
912 ms |
819532 KB |
ok |
94 |
Correct |
831 ms |
811640 KB |
ok |
95 |
Correct |
751 ms |
810584 KB |
ok |
96 |
Correct |
713 ms |
810088 KB |
ok |
97 |
Correct |
704 ms |
809420 KB |
ok |
98 |
Correct |
692 ms |
807504 KB |
ok |
99 |
Correct |
1460 ms |
942164 KB |
ok |
100 |
Correct |
1150 ms |
933488 KB |
ok |
101 |
Correct |
1300 ms |
920208 KB |
ok |
102 |
Correct |
1277 ms |
921904 KB |
ok |
103 |
Correct |
1212 ms |
943892 KB |
ok |
104 |
Correct |
1328 ms |
946180 KB |
ok |
105 |
Correct |
1378 ms |
943360 KB |
ok |
106 |
Correct |
1261 ms |
951556 KB |
ok |
107 |
Correct |
1319 ms |
949276 KB |
ok |
108 |
Correct |
998 ms |
878420 KB |
ok |
109 |
Correct |
1106 ms |
901896 KB |
ok |