This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "wall.h"
#include<iostream>
using namespace std;
const int N=2000000;
int seg[4*N+7];
void update(int l,int r,int idx1,int idx2,int val,int node,int mode){
if(l>idx2 || r<idx1) return ;
if(l==r){
if(mode==1) seg[node]=max(seg[node],val);
else seg[node]=min(seg[node],val);
return ;
}
int mid=(l+r)>>1;
update(l,mid,idx1,idx2,val,node*2,mode);
update(mid+1,r,idx1,idx2,val,node*2+1,mode);
}
void print(int l,int r,int idx1,int idx2, int node,int arr[]){
if(l>idx2 && r<idx1) return ;
if(l==r){
arr[l-1]=seg[node];
return ;
}
int mid=(l+r)>>1;
print(l,mid,idx1,idx2,node*2,arr);
print(mid+1,r,idx1,idx2,node*2+1,arr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for (int i=0;i<k;++i) {
update(1, n, left[i]+1, right[i]+1, height[i], 1, op[i]);
}
print(1,n,1,n,1,finalHeight);
return;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |