# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
481461 | jhhope1 | Secret (JOI14_secret) | C++14 | 455 ms | 4520 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |