# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1131112 | khoavn2008 | Secret (JOI14_secret) | C++20 | 0 ms | 0 KiB |
// #include "secret.h"
#include <bits/stdc++.h>
using namespace std;
const int LOG = 14;
int n, a[LOG + 1][10001];
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; i++)a[0][i] = A[i];
for(int j = 1; j <= LOG; j++)for(int i = 0; i < n - (1 << j) + 1; i++){
a[j][i] = Secret(a[j - 1][i], a[j - 1][i + (1 << (j - 1))]);
}
}
int Query(int L, int R) {
int tmp = __lg(R - L + 1);
return Secret(a[tmp][L], a[tmp][R - (1 << tmp) + 1]);
}