Submission #62646

#TimeUsernameProblemLanguageResultExecution timeMemory
62646DiuvenSecret (JOI14_secret)C++11
0 / 100
722 ms8728 KiB
#include "secret.h" #include <assert.h> static int A[1010]; static int B[1010][1010]; static int n; void init(int s, int e){ if(s==e){ B[s][s]=A[s]; return; } if(e<s) return; int m=(s+e)/2; init(s,m-1); init(m+1,e); B[m][m]=A[m], B[m+1][m+1]=A[m+1]; for(int i=m-1; i>=s; i--) B[i][m]=Secret(A[i], B[i+1][m]); for(int i=m+1; i<=e; i++) B[m+1][i]=Secret(B[m+1][i-1], A[i]); } int get(int s, int e, int l, int r){ int m=(s+e)/2; if(l<=m && m<=r) return m; if(r<m) return get(s,m-1,l,r); if(m<l) return get(m+1,e,l,r); assert(true); } void Init(int N, int _A[]){ n=N; for(int i=0; i<n; i++) A[i]=_A[i]; init(0,n-1); } int Query(int l, int r){ if(l==r) return A[l]; int m=get(0,n-1,l,r); if(m==r) return B[l][m]; else return Secret(B[l][m], B[m+1][r]); }

Compilation message (stderr)

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