Submission #480654

#TimeUsernameProblemLanguageResultExecution timeMemory
480654HaidaraWall (IOI14_wall)C++17
61 / 100
550 ms33604 KiB
#include<bits/stdc++.h> #include<wall.h> #define v(i) vector< i > using namespace std; const int maxn=200200; int n; const int inf=1e9+7; struct node { int mx,mn; node():mx(inf),mn(0) {} } st[maxn*4]; void pull(int inx) { st[inx*2].mn=max(st[inx].mn,min(st[inx*2].mn,st[inx].mx)); st[inx*2].mx=min(st[inx].mx,max(st[inx*2].mx,st[inx].mn)); st[inx*2+1].mn=max(st[inx].mn,min(st[inx*2+1].mn,st[inx].mx)); st[inx*2+1].mx=min(st[inx].mx,max(st[inx*2+1].mx,st[inx].mn)); st[inx].mn=0,st[inx].mx=inf; } bool go; void add(int ql,int qr,int val,int l=0,int r=n-1,int inx=1) { if(ql<=l&&r<=qr) { if(go) { st[inx].mn=max(st[inx].mn,val); st[inx].mx=max(st[inx].mx,val); } else { st[inx].mx=min(val,st[inx].mx); st[inx].mn=min(val,st[inx].mn); } if(l!=r) pull(inx); return ; } if(ql>r||l>qr) return ; pull(inx); int mid=l+(r-l)/2; add(ql,qr,val,l,mid,inx*2); add(ql,qr,val,mid+1,r,inx*2+1); } int query(int pos,int l=0,int r=n-1,int inx=1) { if(l==r) return st[inx].mn; int mid=l+(r-l)/2; pull(inx); if(pos<=mid) return query(pos,l,mid,inx*2); return query(pos,mid+1,r,inx*2+1); } void buildWall(int N, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { n=N; for(int i=0; i<k; i++) { if(op[i]&1) go=1; else go=0; add(left[i],right[i],height[i]); } for(int i=0; i<n; i++) finalHeight[i]=query(i); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...