Submission #979096

#TimeUsernameProblemLanguageResultExecution timeMemory
979096lftroqSecret (JOI14_secret)C++14
0 / 100
362 ms5648 KiB
#include<secret.h> int pref[1005][1005],n,mask[1005]; void dnc(int l,int r,int level,int a[]) { if(l==r) return; int mid=(l+r)>>1; pref[level][mid]=a[mid]; pref[level][mid+1]=a[mid+1]; for(int i=mid+2;i<=r;i++) pref[level][i]=Secret(pref[level][i-1],a[i]); for(int i=mid-1;i>=l;i--) pref[level][i]=Secret(pref[level][i+1],a[i]); for(int i=mid+1;i<=r;i++) mask[i]|=(1<<level); if(l<mid) dnc(l,mid,level+1,a); if(mid+1<r) dnc(mid+1,r,level+1,a); } void Init(int N,int A[]) { dnc(0,N-1,0,A); } int Query(int L,int R) { int k=__builtin_ctz(mask[L]^mask[R]); return Secret(pref[k][L],pref[k][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...