Submission #927224

#TimeUsernameProblemLanguageResultExecution timeMemory
927224NurislamWall (IOI14_wall)C++14
100 / 100
818 ms71508 KiB
//~ #include "wall.h" #include <bits/stdc++.h> //~ #include "grader.cpp" using namespace std; #define pb push_back #define ff first #define ss second #define ll long long typedef vector<ll> vi; typedef pair<ll,ll> pii; typedef vector<pii> vii; const int N = 2e6+5; int add[N*4],rem[N*4]; void build(int v,int tl,int tr){ if(tl==tr){ add[v]=0; rem[v]=1e9; } else{ int tm=(tl+tr)/2; build(v*2,tl,tm); build(v*2+1,tm+1,tr); } } void push(int v){ add[v*2]=max(add[v*2],add[v]); rem[v*2]=max(rem[v*2],add[v]); add[v*2]=min(add[v*2],rem[v]); rem[v*2]=min(rem[v*2],rem[v]); add[v*2+1]=max(add[v*2+1],add[v]); rem[v*2+1]=max(rem[v*2+1],add[v]); add[v*2+1]=min(add[v*2+1],rem[v]); rem[v*2+1]=min(rem[v*2+1],rem[v]); add[v]=0;rem[v]=1e9; } void update(int v,int tl,int tr,int l,int r,int x,int type){ if(r<tl or l>tr)return; if(l<=tl && tr<=r){ if(type==1){ add[v]=max(add[v],x); rem[v]=max(rem[v],x); } else{ add[v]=min(add[v],x); rem[v]=min(rem[v],x); } return; } push(v); int tm=(tl+tr)/2; update(v*2,tl,tm,l,r,x,type); update(v*2+1,tm+1,tr,l,r,x,type); } int get(int v,int tl,int tr,int pos){ if(tl==tr)return add[v]; push(v); int tm=(tl+tr)/2; if(pos<=tm)return get(v*2,tl,tm,pos); else return get(v*2+1,tm+1,tr,pos); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]){ build(1,1,n); for(int i=0;i<k;i++){ update(1,1,n,left[i]+1,right[i]+1,height[i],op[i]); } for(int i=0;i<n;i++){ finalHeight[i]=get(1,1,n,i+1); } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...