# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
481492 |
2021-10-21T03:37:41 Z |
jhhope1 |
Secret (JOI14_secret) |
C++14 |
|
443 ms |
4524 KB |
#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 dep){
if(s==e){
V[dep][s] = orig[s];
return;
}
int m = (s+e)>>1;
build(s, m, dep+1);
build(m+1, e, 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+2 ; i<=e ; i++){
V[dep][i] = Secret(V[dep][i-1], orig[i]);
}
}
void Init(int N, int A[]){
for(int i=0 ; i<N ; i++){
orig[i] = A[i];
}
n = N;
build(0, N-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
secret.cpp: In function 'int eval(int, int, int, int, int)':
secret.cpp:52:1: warning: control reaches end of non-void function [-Wreturn-type]
52 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
120 ms |
2372 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
127 ms |
2552 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
122 ms |
2372 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
427 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
427 ms |
4524 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
423 ms |
4392 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
433 ms |
4504 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
443 ms |
4376 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
426 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
429 ms |
4292 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |