#include"wall.h"
#include<bits/stdc++.h>
using namespace std;
int flag[8000000][2];
void upd(int v,int mn,int mx){
flag[v][0]=min(max(flag[v][0],mn),mx);
flag[v][1]=min(max(flag[v][1],mn),mx);
}
void push(int v,int l,int r){
if(l!=r){
upd(v<<1,flag[v][0],flag[v][1]);
upd((v<<1)+1,flag[v][0],flag[v][1]);
}
flag[v][0]=0;
flag[v][1]=2e9;
}
void update(int v,int l,int r,int ql,int qr,int mn,int mx){
if(ql<=l&&r<=qr){
upd(v,mn,mx);
return;
}
if(r<ql||qr<l)return;
push(v,l,r);
int mid=(l+r)>>1;
update(v<<1,l,mid,ql,qr,mn,mx);
update((v<<1)+1,mid+1,r,ql,qr,mn,mx);
}
void build(int v,int l,int r,int* res){
if(l==r){
res[l]=flag[v][0];
return;
}
int mid=(l+r)>>1;
build(v<<1,l,mid,res);
build((v<<1)+1,mid+1,r,res);
}
void buildWall(int n,int k,int* type,int* l,int* r,int* h,int* res){
for(int i=0;i<k;i++)update(1,0,n-1,l[i],r[i],type[i]^2?h[i]:0,type[i]^1?h[i]:2e9);
build(1,0,n-1,res);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
166 ms |
9592 KB |
Output is correct |
3 |
Incorrect |
192 ms |
8056 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
3 ms |
512 KB |
Output is correct |
3 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |