#include "secret.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int const Mxn = 1e3 + 1;
int const LOGN = 13;
ll ST[LOGN][Mxn];
ll A[Mxn];
int n;
void build(int L = 0, int R = n - 1, int depth = 0) {
if (L == R) return;
int Mid = (L + R)>>1;
for (int i = Mid + 1; i <= R; i++) {
ST[depth][i] = (i == Mid + 1) ? A[i] : Secret(ST[depth][i - 1], A[i]);
}
for (int i = Mid; i >= L; i--) {
ST[depth][i] = (i == Mid) ? A[i] : Secret(A[i], ST[depth][i + 1]);
}
build(L, Mid, depth + 1), build(Mid + 1, R, depth + 1);
}
ll query(int l, int r, int L = 0, int R = n - 1, int depth = 0) {
if (L == R) return A[L];
int Mid = (L + R)>>1;
if (l <= Mid && Mid < r) return Secret(ST[depth][l], ST[depth][r]);
if (r <= Mid) return query(l, r, L, Mid, depth + 1);
else return query(l, r, Mid + 1, R, depth + 1);
}
void Init(int N, int a[]) {
for (int i = 0; i < N; i++) A[i] = a[i];
n = N; build();
}
int Query(int L, int R) {
return query(L, R);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
125 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 |
129 ms |
2384 KB |
Output is correct - number of calls to Secret by Init = 3586, maximum number of calls to Secret by Query = 1 |
3 |
Correct |
133 ms |
2508 KB |
Output is correct - number of calls to Secret by Init = 3595, maximum number of calls to Secret by Query = 1 |
4 |
Correct |
449 ms |
4320 KB |
Output is correct - number of calls to Secret by Init = 7969, maximum number of calls to Secret by Query = 1 |
5 |
Correct |
462 ms |
4380 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
6 |
Correct |
465 ms |
4368 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
7 |
Correct |
471 ms |
4256 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
8 |
Correct |
480 ms |
4360 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
9 |
Correct |
480 ms |
4260 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |
10 |
Correct |
503 ms |
4308 KB |
Output is correct - number of calls to Secret by Init = 7978, maximum number of calls to Secret by Query = 1 |