Submission #930304

#TimeUsernameProblemLanguageResultExecution timeMemory
930304noyancanturkSecret (JOI14_secret)C++17
0 / 100
358 ms4532 KiB
#include "secret.h" #include <cassert> const int lim=1100; int n,*a; int left[15][lim],right[15][lim]; void dnc(int l,int r,int dep=0){ if(l==r){ return; } int mid=(l+r)>>1; left[dep][mid]=a[mid]; for(int i=mid-1;l<=i;i--){ left[dep][i]=Secret(a[i],left[dep][i+1]); } right[dep][mid+1]=a[mid+1]; for(int i=mid+2;i<=r;i++){ right[dep][i]=Secret(right[dep][i-1],a[i]); } dnc(l,mid,dep+1),dnc(mid+1,r,dep+1); } void Init(int N, int A[]) { n=N; a=A; dnc(0,n-1); } int Query(int L, int R) { if(L==R){ return a[L]; } int l=0,r=n-1,dep=0; while(l<=r){ int mid=(l+r)>>1; if(L==mid+1)return right[dep][mid+1]; if(L<=mid&&mid<R){ return Secret(left[dep][L],right[dep][R]); }else if(mid==R){ return left[dep][L]; }else if(mid<L){ l=mid+1; }else{ r=mid-1; } dep++; } return -1; }
#Verdict Execution timeMemoryGrader output
Fetching results...