Submission #67847

#TimeUsernameProblemLanguageResultExecution timeMemory
67847VahanWall (IOI14_wall)C++17
8 / 100
3046 ms34688 KiB
#include "wall.h" #include<algorithm> using namespace std; int t[17000000]; void update(int l,int r,int L,int R,int v,int a,int b) { if(l>r) return; if(l==L && r==R && t[v]!=-1) { if(t[v]<a && b==1) t[v]=a; if(t[v]>a && b==2) t[v]=a; return; } if(t[v]!=-1) { t[2*v]=t[v]; t[2*v+1]=t[v]; t[v]=-1; } int mid=(L+R)/2; update(l,min(mid,r),L,mid,2*v,a,b); update(max(l,mid+1),r,mid+1,R,2*v+1,a,b); } int get(int l,int r,int v,int a) { if(l==r) return t[v]; if(t[v]!=-1) { t[2*v]=t[v]; t[2*v+1]=t[v]; t[v]=-1; } int mid=(l+r)/2; if(a<=mid) get(l,mid,2*v,a); else get(mid+1,r,2*v+1,a); } void buildWall(int n, int k, int op[], int left[], int right[], int height[], int finalHeight[]) { for(int i=0;i<k;i++) update(left[i],right[i],0,n-1,1,height[i],op[i]); for(int i=0;i<n;i++) finalHeight[i]=get(0,n-1,1,i); return; }

Compilation message (stderr)

wall.cpp: In function 'int get(int, int, int, int)':
wall.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...