#include "wall.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
int ans[2000005];
int v[8000005][2];
void upd(int x,int mn,int mx){
v[x][0]=min(max(mn,v[x][0]),mx);
v[x][1]=min(max(mn,v[x][1]),mx);
}
void push(int x,int l,int r){
if(l!=r){
upd(x*2,v[x][0],v[x][1]);
upd(x*2+1,v[x][0],v[x][1]);
}
v[x][1]=INT_MAX;
v[x][0]=0;
}
void update(int x,int lx,int rx,int l,int r,int mn,int mx){
if(lx>=l&&r>=rx){
upd(x,mn,mx);
return;
}
if(rx<l||lx>r)
return;
push(x,lx,rx);
int m=(lx+rx)/2;
update(x*2,lx,m,l,r,mn,mx);
update(x*2+1,m+1,rx,l,r,mn,mx);
}
void build(int x,int l,int r){
if(l==r){
ans[l]=v[x][0];
return;
}
push(x,l,r);
int m=(l+r)/2;
build(x*2,l,m);
build(x*2+1,m+1,r);
}
void buildWall(int n, int k, int w[], int l[], int r[], int h[], int a[]){
for(int i=0;i<k;i++){
int mn=(w[i]==1 ? h[i]:0),mx=(w[i]==2 ? h[i]:INT_MAX);
update(1,0,n-1,l[i],r[i],mn,mx);
}
build(1,0,n-1);
for(int i=0;i<n;i++)
a[i]=ans[i];
return ;
}
/*
10 6
1 1 8 4
2 4 9 1
2 3 6 5
1 0 5 3
1 2 2 5
2 6 7 0
*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
185 ms |
8184 KB |
Output is correct |
3 |
Correct |
198 ms |
4344 KB |
Output is correct |
4 |
Correct |
547 ms |
11256 KB |
Output is correct |
5 |
Correct |
340 ms |
11768 KB |
Output is correct |
6 |
Correct |
335 ms |
11792 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
768 KB |
Output is correct |
5 |
Correct |
5 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
175 ms |
8136 KB |
Output is correct |
9 |
Correct |
189 ms |
4344 KB |
Output is correct |
10 |
Correct |
540 ms |
11448 KB |
Output is correct |
11 |
Correct |
343 ms |
11896 KB |
Output is correct |
12 |
Correct |
329 ms |
11768 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
180 ms |
8312 KB |
Output is correct |
15 |
Correct |
31 ms |
1528 KB |
Output is correct |
16 |
Correct |
549 ms |
11540 KB |
Output is correct |
17 |
Correct |
340 ms |
11404 KB |
Output is correct |
18 |
Correct |
337 ms |
11512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
7 ms |
768 KB |
Output is correct |
5 |
Correct |
6 ms |
768 KB |
Output is correct |
6 |
Correct |
6 ms |
768 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
178 ms |
8184 KB |
Output is correct |
9 |
Correct |
193 ms |
4268 KB |
Output is correct |
10 |
Correct |
533 ms |
11256 KB |
Output is correct |
11 |
Correct |
355 ms |
11776 KB |
Output is correct |
12 |
Correct |
335 ms |
11768 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
174 ms |
8184 KB |
Output is correct |
15 |
Correct |
32 ms |
1532 KB |
Output is correct |
16 |
Correct |
550 ms |
11512 KB |
Output is correct |
17 |
Correct |
332 ms |
11512 KB |
Output is correct |
18 |
Correct |
337 ms |
11512 KB |
Output is correct |
19 |
Correct |
787 ms |
67192 KB |
Output is correct |
20 |
Correct |
784 ms |
64632 KB |
Output is correct |
21 |
Correct |
807 ms |
67096 KB |
Output is correct |
22 |
Correct |
778 ms |
64632 KB |
Output is correct |
23 |
Correct |
780 ms |
64412 KB |
Output is correct |
24 |
Correct |
779 ms |
64444 KB |
Output is correct |
25 |
Correct |
785 ms |
64504 KB |
Output is correct |
26 |
Correct |
787 ms |
67304 KB |
Output is correct |
27 |
Correct |
786 ms |
67320 KB |
Output is correct |
28 |
Correct |
783 ms |
64420 KB |
Output is correct |
29 |
Correct |
779 ms |
64404 KB |
Output is correct |
30 |
Correct |
787 ms |
64668 KB |
Output is correct |