#include "soccer.h"
#include <bits/stdc++.h>
int n,next[2010][2010],sum[2010][2010],ans;
std::map<std::pair<std::pair<int,int>,std::pair<int,int>>,int>val;
std::priority_queue<std::pair<int,std::pair<std::pair<int,int>,std::pair<int,int>>>>q;
int suma(int i,int ii,int j,int jj)
{
return sum[ii+1][jj+1]-sum[ii+1][j]-sum[i][jj+1]+sum[i][j];
}
void adauga(int up,int down,int l,int r,int valac)
{
int b=0,e=up-1;
while(b<=e)
{
int m=(b+e)/2;
if(suma(m,up,l,r)==0)
e=m-1;
else
b=m+1;
}
valac+=(r-l+1)*(up-b);
up=b;
b=down+1,e=n-1;
while(b<=e)
{
int m=(b+e)/2;
if(suma(down,m,l,r)==0)
b=m+1;
else
e=m-1;
}
valac+=(r-l+1)*(e-down);
down=e;
std::pair<std::pair<int,int>,std::pair<int,int>>cod={{up,down},{l,r}};
if(val.find(cod)==val.end())
{
q.push({up-down,cod});
val[cod]=valac;
}
else
if(valac>val[cod])
val[cod]=valac;
if(valac>ans)
ans=valac;
}
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
n=N;
for(int i=1;i<=n;++i)
for(int j=1;j<=n;++j)
sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+F[i-1][j-1];
for(int i=0;i<n;++i)
{
next[i][n]=n-1;
for(int j=n-1;j>=0;--j)
{
if(F[i][j]==1)
next[i][j]=j-1;
else
next[i][j]=next[i][j+1];
}
}
for(int i=0;i<n;++i)
{
int poz=0;
while(poz!=n)
{
if(next[i][poz]<poz)
++poz;
else
{
adauga(i,i,poz,next[i][poz],next[i][poz]-poz+1);
poz=next[i][poz]+1;
}
}
}
while(!q.empty())
{
std::pair<std::pair<int,int>,std::pair<int,int>>cod=q.top().second;
q.pop();
int up=cod.first.first;
int down=cod.first.second;
int l=cod.second.first;
int r=cod.second.second;
if(up)
{
int poz=l;
while(poz<=r)
{
if(next[up-1][poz]>=poz)
{
adauga(up-1,down,poz,std::min(next[up-1][poz],r),val[cod]+std::min(next[up-1][poz],r)-poz+1);
poz=next[up-1][poz]+1;
}
else
++poz;
}
}
if(down+1!=n)
{
int poz=l;
while(poz<=r)
{
if(next[down+1][poz]>=poz)
{
adauga(up,down+1,poz,std::min(next[down+1][poz],r),val[cod]+std::min(next[down+1][poz],r)-poz+1);
poz=next[down+1][poz]+1;
}
else
++poz;
}
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 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 |
444 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
1372 KB |
ok |
8 |
Correct |
16 ms |
8788 KB |
ok |
9 |
Correct |
217 ms |
70920 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
344 KB |
ok |
7 |
Correct |
0 ms |
448 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 |
1 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
444 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 |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
344 KB |
ok |
8 |
Correct |
0 ms |
448 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 |
1 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
444 KB |
ok |
15 |
Correct |
1 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
1 ms |
444 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
344 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
0 ms |
348 KB |
ok |
23 |
Correct |
1 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
344 KB |
ok |
25 |
Correct |
1 ms |
600 KB |
ok |
26 |
Correct |
0 ms |
440 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 |
444 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
448 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 |
1 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
444 KB |
ok |
17 |
Correct |
1 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
444 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
1 ms |
344 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
1 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
1 ms |
600 KB |
ok |
28 |
Correct |
0 ms |
440 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
1 ms |
700 KB |
ok |
31 |
Correct |
1 ms |
604 KB |
ok |
32 |
Correct |
1 ms |
600 KB |
ok |
33 |
Correct |
1 ms |
604 KB |
ok |
34 |
Correct |
0 ms |
604 KB |
ok |
35 |
Correct |
0 ms |
604 KB |
ok |
36 |
Correct |
1 ms |
600 KB |
ok |
37 |
Correct |
0 ms |
604 KB |
ok |
38 |
Correct |
1 ms |
600 KB |
ok |
39 |
Correct |
0 ms |
604 KB |
ok |
40 |
Correct |
0 ms |
604 KB |
ok |
41 |
Correct |
1 ms |
604 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 |
444 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
344 KB |
ok |
10 |
Correct |
0 ms |
448 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 |
1 ms |
348 KB |
ok |
15 |
Correct |
0 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
444 KB |
ok |
17 |
Correct |
1 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
444 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Correct |
1 ms |
344 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
1 ms |
348 KB |
ok |
26 |
Correct |
0 ms |
344 KB |
ok |
27 |
Correct |
1 ms |
600 KB |
ok |
28 |
Correct |
0 ms |
440 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
1 ms |
700 KB |
ok |
31 |
Correct |
1 ms |
604 KB |
ok |
32 |
Correct |
1 ms |
600 KB |
ok |
33 |
Correct |
1 ms |
604 KB |
ok |
34 |
Correct |
0 ms |
604 KB |
ok |
35 |
Correct |
0 ms |
604 KB |
ok |
36 |
Correct |
1 ms |
600 KB |
ok |
37 |
Correct |
0 ms |
604 KB |
ok |
38 |
Correct |
1 ms |
600 KB |
ok |
39 |
Correct |
0 ms |
604 KB |
ok |
40 |
Correct |
0 ms |
604 KB |
ok |
41 |
Correct |
1 ms |
604 KB |
ok |
42 |
Correct |
88 ms |
12396 KB |
ok |
43 |
Correct |
92 ms |
13540 KB |
ok |
44 |
Correct |
50 ms |
9808 KB |
ok |
45 |
Correct |
31 ms |
9300 KB |
ok |
46 |
Correct |
71 ms |
11180 KB |
ok |
47 |
Correct |
15 ms |
8792 KB |
ok |
48 |
Correct |
15 ms |
8796 KB |
ok |
49 |
Correct |
15 ms |
8848 KB |
ok |
50 |
Correct |
32 ms |
8924 KB |
ok |
51 |
Correct |
27 ms |
10364 KB |
ok |
52 |
Correct |
15 ms |
8792 KB |
ok |
53 |
Correct |
15 ms |
8792 KB |
ok |
54 |
Correct |
15 ms |
8796 KB |
ok |
55 |
Correct |
16 ms |
8796 KB |
ok |
56 |
Correct |
15 ms |
8792 KB |
ok |
57 |
Correct |
62 ms |
12680 KB |
ok |
58 |
Correct |
77 ms |
13392 KB |
ok |
59 |
Correct |
78 ms |
13904 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 |
444 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
1372 KB |
ok |
9 |
Correct |
16 ms |
8788 KB |
ok |
10 |
Correct |
217 ms |
70920 KB |
ok |
11 |
Correct |
1 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 |
0 ms |
448 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 |
1 ms |
348 KB |
ok |
20 |
Correct |
0 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
444 KB |
ok |
22 |
Correct |
1 ms |
348 KB |
ok |
23 |
Correct |
0 ms |
348 KB |
ok |
24 |
Correct |
0 ms |
348 KB |
ok |
25 |
Correct |
1 ms |
444 KB |
ok |
26 |
Correct |
0 ms |
348 KB |
ok |
27 |
Correct |
1 ms |
344 KB |
ok |
28 |
Correct |
0 ms |
348 KB |
ok |
29 |
Correct |
0 ms |
348 KB |
ok |
30 |
Correct |
1 ms |
348 KB |
ok |
31 |
Correct |
0 ms |
344 KB |
ok |
32 |
Correct |
1 ms |
600 KB |
ok |
33 |
Correct |
0 ms |
440 KB |
ok |
34 |
Correct |
0 ms |
348 KB |
ok |
35 |
Correct |
1 ms |
700 KB |
ok |
36 |
Correct |
1 ms |
604 KB |
ok |
37 |
Correct |
1 ms |
600 KB |
ok |
38 |
Correct |
1 ms |
604 KB |
ok |
39 |
Correct |
0 ms |
604 KB |
ok |
40 |
Correct |
0 ms |
604 KB |
ok |
41 |
Correct |
1 ms |
600 KB |
ok |
42 |
Correct |
0 ms |
604 KB |
ok |
43 |
Correct |
1 ms |
600 KB |
ok |
44 |
Correct |
0 ms |
604 KB |
ok |
45 |
Correct |
0 ms |
604 KB |
ok |
46 |
Correct |
1 ms |
604 KB |
ok |
47 |
Correct |
88 ms |
12396 KB |
ok |
48 |
Correct |
92 ms |
13540 KB |
ok |
49 |
Correct |
50 ms |
9808 KB |
ok |
50 |
Correct |
31 ms |
9300 KB |
ok |
51 |
Correct |
71 ms |
11180 KB |
ok |
52 |
Correct |
15 ms |
8792 KB |
ok |
53 |
Correct |
15 ms |
8796 KB |
ok |
54 |
Correct |
15 ms |
8848 KB |
ok |
55 |
Correct |
32 ms |
8924 KB |
ok |
56 |
Correct |
27 ms |
10364 KB |
ok |
57 |
Correct |
15 ms |
8792 KB |
ok |
58 |
Correct |
15 ms |
8792 KB |
ok |
59 |
Correct |
15 ms |
8796 KB |
ok |
60 |
Correct |
16 ms |
8796 KB |
ok |
61 |
Correct |
15 ms |
8792 KB |
ok |
62 |
Correct |
62 ms |
12680 KB |
ok |
63 |
Correct |
77 ms |
13392 KB |
ok |
64 |
Correct |
78 ms |
13904 KB |
ok |
65 |
Correct |
2206 ms |
130548 KB |
ok |
66 |
Correct |
926 ms |
132344 KB |
ok |
67 |
Correct |
416 ms |
98588 KB |
ok |
68 |
Correct |
328 ms |
73724 KB |
ok |
69 |
Correct |
927 ms |
86568 KB |
ok |
70 |
Correct |
1402 ms |
97724 KB |
ok |
71 |
Correct |
286 ms |
72600 KB |
ok |
72 |
Correct |
207 ms |
70996 KB |
ok |
73 |
Correct |
264 ms |
71248 KB |
ok |
74 |
Correct |
276 ms |
71064 KB |
ok |
75 |
Correct |
212 ms |
71248 KB |
ok |
76 |
Correct |
632 ms |
71248 KB |
ok |
77 |
Correct |
641 ms |
71200 KB |
ok |
78 |
Correct |
338 ms |
84448 KB |
ok |
79 |
Correct |
306 ms |
76512 KB |
ok |
80 |
Correct |
262 ms |
74916 KB |
ok |
81 |
Correct |
309 ms |
74788 KB |
ok |
82 |
Correct |
355 ms |
78816 KB |
ok |
83 |
Correct |
607 ms |
94872 KB |
ok |
84 |
Correct |
215 ms |
71188 KB |
ok |
85 |
Correct |
222 ms |
71256 KB |
ok |
86 |
Correct |
240 ms |
71196 KB |
ok |
87 |
Correct |
232 ms |
72212 KB |
ok |
88 |
Correct |
218 ms |
70992 KB |
ok |
89 |
Correct |
267 ms |
70992 KB |
ok |
90 |
Correct |
212 ms |
71060 KB |
ok |
91 |
Correct |
209 ms |
71252 KB |
ok |
92 |
Correct |
361 ms |
86172 KB |
ok |
93 |
Correct |
433 ms |
89232 KB |
ok |
94 |
Correct |
284 ms |
77796 KB |
ok |
95 |
Correct |
241 ms |
74544 KB |
ok |
96 |
Correct |
231 ms |
73324 KB |
ok |
97 |
Correct |
225 ms |
72800 KB |
ok |
98 |
Correct |
224 ms |
72020 KB |
ok |
99 |
Correct |
1414 ms |
140244 KB |
ok |
100 |
Correct |
1129 ms |
134064 KB |
ok |
101 |
Correct |
1141 ms |
127824 KB |
ok |
102 |
Correct |
1188 ms |
133968 KB |
ok |
103 |
Correct |
1349 ms |
144596 KB |
ok |
104 |
Correct |
1468 ms |
148500 KB |
ok |
105 |
Correct |
1484 ms |
151612 KB |
ok |
106 |
Correct |
1464 ms |
154796 KB |
ok |
107 |
Correct |
1398 ms |
154104 KB |
ok |
108 |
Correct |
371 ms |
76968 KB |
ok |
109 |
Correct |
372 ms |
76772 KB |
ok |