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<bits/stdc++.h>
using namespace std;
pair<int,int> seg[8000010];
void push(int l,int r,int idx){
if(l==r)return;
seg[idx*2].first = max(seg[idx*2].first,seg[idx].first);
seg[idx*2].first = min(seg[idx*2].first,seg[idx].second);
seg[idx*2].second = max(seg[idx*2].second,seg[idx].first);
seg[idx*2].second = min(seg[idx*2].second,seg[idx].second);
seg[idx*2+1].first = max(seg[idx*2+1].first,seg[idx].first);
seg[idx*2+1].first = min(seg[idx*2+1].first,seg[idx].second);
seg[idx*2+1].second = max(seg[idx*2+1].second,seg[idx].first);
seg[idx*2+1].second = min(seg[idx*2+1].second,seg[idx].second);
seg[idx] = {-1e9,1e9};
}
void p(int fh[],int l,int r,int idx){
if(l==r){
fh[l] = seg[idx].first;
return;
}
push(l,r,idx);
int m = (l+r)>>1;
p(fh,l,m,idx*2);
p(fh,m+1,r,idx*2+1);
}
void upd(int l,int r,int idx,int val,int op,int ll,int rr){
if(l>rr || r<ll)return;
if(l>=ll && r<=rr){
if(op==1){
seg[idx].first = max(val,seg[idx].first);
seg[idx].second = max(val,seg[idx].second);
}
else{
seg[idx].first = min(val,seg[idx].first);
seg[idx].second = min(val,seg[idx].second);
}
return;
}
push(l,r,idx);
int m = (l+r)>>1;
upd(l,m,idx*2,val,op,ll,rr);
upd(m+1,r,idx*2+1,val,op,ll,rr);
}
void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){
for(int i = 0;i<k;i++){
upd(1,n,1,height[i],op[i],left[i],right[i]);
}
p(finalHeight,1,n,1);
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... |