#include "wall.h"
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pub push_back
#define pob pop_back
#define ss second
#define ff first
#define ext exit(0)
using namespace std;
int o,a[2000001],lax[4000001],lam[4000001],fin[2000001];
void init(int node, int l , int r){
if(l==r){
lam[node]=1e9;
return;
}
int mid=(l+r)/2;
init(node*2,l,mid);
init(node*2+1,mid+1,r);
lam[node]=1e9;
}
void mx(int node, int h){
lax[node]=max(lax[node],h);
lam[node]=max(lam[node],lax[node]);
}
void mn(int node, int h){
lam[node]=min(lam[node],h);
lax[node]=min(lax[node],lam[node]);
}
void push(int node,int l , int r){
mx(node*2,lax[node]);
mx(node*2+1,lax[node]);
mn(node*2,lam[node]);
mn(node*2+1,lam[node]);
lax[node]=0;
lax[node]=1e9;
}
void query(int node,int l , int r, int L , int R, int h, int o){
if(l>R || r< L) return;
if(l>=L && r<=R) {
if(o==1)mx(node,h);
else mn(node,h);
return ;
}
push(node,l,r);
int mid=(l+r)/2;
query(node*2,l,mid,L,R,h,o);
query(node*2+1,mid+1,r,L,R,h,o);
}
void f(int node, int l , int r){
if(l==r){
fin[l]=lax[node];
return ;
}
int mid=(l+r)/2;
f(node*2,l,mid);
f(node*2+1,mid+1,r);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
init(1,1,n);
for(int i=0;i<k;i++){
left[i]++;
right[i]++;
query(1,1,n,left[i],right[i],height[i],op[i]);
}
f(1,1,n);
for(int i=1;i<=n;i++) finalHeight[i-1]=fin[i];
return;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
6 ms |
616 KB |
Output is correct |
3 |
Incorrect |
5 ms |
792 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
792 KB |
Output is correct |
2 |
Correct |
219 ms |
14500 KB |
Output is correct |
3 |
Incorrect |
281 ms |
14500 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
14500 KB |
Output is correct |
2 |
Correct |
7 ms |
14500 KB |
Output is correct |
3 |
Incorrect |
5 ms |
14500 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
14500 KB |
Output is correct |
2 |
Correct |
8 ms |
14500 KB |
Output is correct |
3 |
Incorrect |
5 ms |
14500 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |