Submission #481461

#TimeUsernameProblemLanguageResultExecution timeMemory
481461jhhope1Secret (JOI14_secret)C++14
0 / 100
455 ms4520 KiB
#include<bits/stdc++.h> #include<secret.h> const int MAXN = 1010; int n; int orig[MAXN]; int V[12][MAXN]; void build(int s, int e, int v, int dep){ if(s==e){ V[dep][s] = orig[s]; return; } int m = (s+e)>>1; build(s, m, v*2, dep+1); build(m+1, e, v*2+1, dep+1); V[dep][m] = orig[m]; V[dep][m+1] = orig[m+1]; for(int i=m-1 ; i>=s ; i--){ V[dep][i] = Secret(orig[i], V[dep][i+1]); } for(int i=m+1 ; i<=e ; i++){ V[dep][i] = Secret(orig[i], V[dep][i-1]); } } void Init(int N, int A[]){ for(int i=0 ; i<N ; i++){ orig[i] = A[i]; } n = N; build(0, N-1, 1, 0); return ; } int eval(int s, int e, int l, int r, int dep){ if(s==e){ return orig[s]; } int m = (s+e)>>1; if(l<=m && m+1<=r){ return Secret(V[dep][l], V[dep][r]); } if(r==m){ return V[dep][l]; } if(l==m+1){ return V[dep][r]; } if(l>m+1){ return eval(m+1, e, l, r, dep+1); } if(r<m){ return eval(s, m, l, r, dep+1); } } int Query(int L, int R){ return eval(0, n-1, L, R, 0); }

Compilation message (stderr)

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