#include "wall.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll i,mi[8080808],ma[8080808],h[2020202];
void tum(ll aa,ll bb,ll cc)
{
mi[aa]=min(mi[aa],bb);
ma[aa]=min(ma[aa],bb);
ma[aa]=max(ma[aa],cc);
}
void upd(ll aa,ll bb,ll cc,ll dd,ll ee,ll ff,ll gg)
{
if(aa==bb)
h[aa]=ma[ee];
else
if(mi[ee]!=1e17||ma[ee]!=0)
{
tum(ee*2,mi[ee],ma[ee]);
tum(ee*2+1,mi[ee],ma[ee]);
mi[ee]=1e17;
ma[ee]=0;
}
if(bb<cc||dd<aa)
return ;
else
if(cc<=aa&&bb<=dd)
tum(ee,ff,gg);
else
{
upd(aa,(aa+bb)/2,cc,dd,ee*2,ff,gg);
upd((aa+bb)/2+1,bb,cc,dd,ee*2+1,ff,gg);
}
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(i=1;i<=4*n;i++)
mi[i]=1e17;
for(i=0;i<k;i++)
if(op[i]==1)
upd(0,n-1,left[i],right[i],1,1e17,height[i]);
else
upd(0,n-1,left[i],right[i],1,height[i],0);
for(i=0;i<n;i++)
upd(0,n-1,i,i,1,1e17,0);
for(i=0;i<n;i++)
finalHeight[i]=h[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
4 ms |
508 KB |
Output is correct |
3 |
Correct |
3 ms |
512 KB |
Output is correct |
4 |
Correct |
10 ms |
1600 KB |
Output is correct |
5 |
Correct |
10 ms |
1600 KB |
Output is correct |
6 |
Correct |
8 ms |
1660 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1660 KB |
Output is correct |
2 |
Correct |
181 ms |
14476 KB |
Output is correct |
3 |
Correct |
228 ms |
15032 KB |
Output is correct |
4 |
Correct |
757 ms |
34600 KB |
Output is correct |
5 |
Correct |
366 ms |
45276 KB |
Output is correct |
6 |
Correct |
331 ms |
53680 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
53680 KB |
Output is correct |
2 |
Correct |
5 ms |
53680 KB |
Output is correct |
3 |
Correct |
3 ms |
53680 KB |
Output is correct |
4 |
Correct |
11 ms |
53680 KB |
Output is correct |
5 |
Correct |
9 ms |
53680 KB |
Output is correct |
6 |
Correct |
8 ms |
53680 KB |
Output is correct |
7 |
Correct |
1 ms |
53680 KB |
Output is correct |
8 |
Correct |
166 ms |
53680 KB |
Output is correct |
9 |
Correct |
253 ms |
53680 KB |
Output is correct |
10 |
Correct |
716 ms |
72968 KB |
Output is correct |
11 |
Correct |
353 ms |
83612 KB |
Output is correct |
12 |
Correct |
355 ms |
92224 KB |
Output is correct |
13 |
Correct |
2 ms |
92224 KB |
Output is correct |
14 |
Correct |
215 ms |
92224 KB |
Output is correct |
15 |
Correct |
39 ms |
92224 KB |
Output is correct |
16 |
Correct |
781 ms |
107824 KB |
Output is correct |
17 |
Correct |
443 ms |
116888 KB |
Output is correct |
18 |
Correct |
340 ms |
125964 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
125964 KB |
Output is correct |
2 |
Correct |
3 ms |
125964 KB |
Output is correct |
3 |
Correct |
4 ms |
125964 KB |
Output is correct |
4 |
Correct |
17 ms |
125964 KB |
Output is correct |
5 |
Correct |
13 ms |
125964 KB |
Output is correct |
6 |
Correct |
9 ms |
125964 KB |
Output is correct |
7 |
Correct |
2 ms |
125964 KB |
Output is correct |
8 |
Correct |
202 ms |
125964 KB |
Output is correct |
9 |
Correct |
233 ms |
125964 KB |
Output is correct |
10 |
Correct |
745 ms |
145316 KB |
Output is correct |
11 |
Correct |
397 ms |
156028 KB |
Output is correct |
12 |
Correct |
348 ms |
164384 KB |
Output is correct |
13 |
Correct |
2 ms |
164384 KB |
Output is correct |
14 |
Correct |
235 ms |
164384 KB |
Output is correct |
15 |
Correct |
42 ms |
164384 KB |
Output is correct |
16 |
Correct |
775 ms |
180352 KB |
Output is correct |
17 |
Correct |
361 ms |
189328 KB |
Output is correct |
18 |
Correct |
393 ms |
198360 KB |
Output is correct |
19 |
Correct |
1414 ms |
262144 KB |
Output is correct |
20 |
Correct |
1450 ms |
262144 KB |
Output is correct |
21 |
Correct |
1385 ms |
262144 KB |
Output is correct |
22 |
Correct |
1376 ms |
262144 KB |
Output is correct |
23 |
Correct |
1358 ms |
262144 KB |
Output is correct |
24 |
Correct |
1397 ms |
262144 KB |
Output is correct |
25 |
Correct |
1372 ms |
262144 KB |
Output is correct |
26 |
Correct |
1325 ms |
262144 KB |
Output is correct |
27 |
Correct |
1480 ms |
262144 KB |
Output is correct |
28 |
Correct |
1409 ms |
262144 KB |
Output is correct |
29 |
Correct |
1427 ms |
262144 KB |
Output is correct |
30 |
Correct |
1360 ms |
262144 KB |
Output is correct |