# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
52543 |
2018-06-26T06:59:42 Z |
kriii |
Secret (JOI14_secret) |
C++17 |
|
660 ms |
4696 KB |
#include "secret.h"
int n, a[1010];
int u[10][1010];
void go(int d, int l, int r)
{
if (l == r) return;
int m = (l + r) / 2;
u[d][m] = a[m];
for (int i = m-1; i >= l; i--) {
u[d][i] = Secret(a[i],u[d][i+1]);
}
u[d][m + 1] = a[m + 1];
for (int i = m + 2; i <= r; i++) {
u[d][i] = Secret(u[d][i-1],a[i]);
}
go(d + 1, l, m);
go(d + 1, m + 1, r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++) a[i] = A[i];
go(0, 0, N - 1);
}
int go2(int d, int l, int r, int L, int R)
{
if (r < L || R < l) return 0;
int m = (l + r) / 2;
if (R == m) return u[d][L];
if (L == m + 1) return u[d][R];
if (L <= m && m + 1 <= R) return Secret(u[d][L], u[d][R]);
int p = go2(d + 1, l, m, L, R);
int q = go2(d + 1, m + 1, r, L, R);
return p + q;
}
int Query(int L, int R) {
if (L == R) return a[L];
return go2(0,0,n-1,L,R);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
168 ms |
2424 KB |
Output is correct - number of calls to Secret by Init = 3578, maximum number of calls to Secret by Query = 1 |
2 |
Correct |
173 ms |
2620 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
167 ms |
2620 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
595 ms |
4496 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
595 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
660 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
634 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
595 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
608 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
580 ms |
4696 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |