#include "wall.h"
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e6+5;
int Max[4*maxn],Min[4*maxn],res[maxn];
void pull(int id){
Max[id]=max(Max[id<<1],Max[id<<1|1]);
Min[id]=min(Min[id<<1],Min[id<<1|1]);
}
void getnew(int id,int val){
Max[id]=Min[id]=val;
}
void pushdown(int id){
if(Min[id]!=Max[id]) return;
getnew(id<<1,Min[id]);
getnew(id<<1|1,Min[id]);
}
void update_Max(int l,int r,int id,int tl,int tr,int x){
if(x<=Min[id] || tr<l || r<tl) return;
if(tl<=l && r<=tr && x>=Max[id]){
getnew(id,x);
return;
}
pushdown(id);
int mid=(l+r)>>1;
update_Max(l,mid,id<<1,tl,tr,x);update_Max(mid+1,r,id<<1|1,tl,tr,x);
pull(id);
}
void update_Min(int l,int r,int id,int tl,int tr,int x){
if(x>=Max[id] || tr<l || r<tl) return;
if(tl<=l && r<=tr && x<=Min[id]){
getnew(id,x);
return;
}
pushdown(id);
int mid=(l+r)>>1;
update_Min(l,mid,id<<1,tl,tr,x);update_Min(mid+1,r,id<<1|1,tl,tr,x);
pull(id);
}
void build(int l,int r,int id){
if(l==r){
res[l]=Min[id];
return;
}
pushdown(id);
int mid=(l+r)>>1;
build(l,mid,id<<1);build(mid+1,r,id<<1|1);
}
void buildWall(int n, int k, int op[], int left[], int right[],
int height[], int finalHeight[]){
for(int i=0;i<k;i++){
if(op[i]==1) update_Max(0,n-1,1,left[i],right[i],height[i]);
else update_Min(0,n-1,1,left[i],right[i],height[i]);
}
build(0,n-1,1);
for(int i=0;i<n;i++) finalHeight[i]=res[i];
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
824 KB |
Output is correct |
5 |
Correct |
4 ms |
828 KB |
Output is correct |
6 |
Correct |
4 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
117 ms |
13856 KB |
Output is correct |
3 |
Correct |
57 ms |
8012 KB |
Output is correct |
4 |
Correct |
140 ms |
20812 KB |
Output is correct |
5 |
Correct |
148 ms |
21824 KB |
Output is correct |
6 |
Correct |
167 ms |
20324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
852 KB |
Output is correct |
5 |
Correct |
4 ms |
832 KB |
Output is correct |
6 |
Correct |
4 ms |
852 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
112 ms |
13924 KB |
Output is correct |
9 |
Correct |
57 ms |
8028 KB |
Output is correct |
10 |
Correct |
143 ms |
20760 KB |
Output is correct |
11 |
Correct |
144 ms |
21760 KB |
Output is correct |
12 |
Correct |
160 ms |
20228 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
116 ms |
13956 KB |
Output is correct |
15 |
Correct |
19 ms |
2032 KB |
Output is correct |
16 |
Correct |
320 ms |
21084 KB |
Output is correct |
17 |
Correct |
232 ms |
20400 KB |
Output is correct |
18 |
Correct |
220 ms |
20408 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
4 ms |
852 KB |
Output is correct |
5 |
Correct |
4 ms |
824 KB |
Output is correct |
6 |
Correct |
4 ms |
852 KB |
Output is correct |
7 |
Correct |
0 ms |
308 KB |
Output is correct |
8 |
Correct |
112 ms |
13976 KB |
Output is correct |
9 |
Correct |
56 ms |
8028 KB |
Output is correct |
10 |
Correct |
144 ms |
20812 KB |
Output is correct |
11 |
Correct |
145 ms |
21752 KB |
Output is correct |
12 |
Correct |
163 ms |
20284 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
115 ms |
13860 KB |
Output is correct |
15 |
Correct |
18 ms |
2020 KB |
Output is correct |
16 |
Correct |
317 ms |
20996 KB |
Output is correct |
17 |
Correct |
222 ms |
20472 KB |
Output is correct |
18 |
Correct |
226 ms |
20376 KB |
Output is correct |
19 |
Correct |
501 ms |
77388 KB |
Output is correct |
20 |
Correct |
494 ms |
74812 KB |
Output is correct |
21 |
Correct |
484 ms |
77272 KB |
Output is correct |
22 |
Correct |
494 ms |
74832 KB |
Output is correct |
23 |
Correct |
494 ms |
74860 KB |
Output is correct |
24 |
Correct |
479 ms |
74840 KB |
Output is correct |
25 |
Correct |
499 ms |
74824 KB |
Output is correct |
26 |
Correct |
489 ms |
77388 KB |
Output is correct |
27 |
Correct |
497 ms |
77276 KB |
Output is correct |
28 |
Correct |
505 ms |
74768 KB |
Output is correct |
29 |
Correct |
487 ms |
74836 KB |
Output is correct |
30 |
Correct |
480 ms |
74824 KB |
Output is correct |