# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703282 | bane | Secret (JOI14_secret) | C++17 | 447 ms | 8932 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"
using namespace std;
typedef long long ll;
const int MAX = 1e6+5;
ll arr[MAX], ret[20][MAX], mask[MAX];
int n;
void solve(){
}
void Init(int N_, int A[]) {
n = N_;
for (int i = 0; i < n; ++i)arr[i] = A[i];
function<void(int,int,int)>init = [&](int l, int r, int dep = 0){
if (l == r) return;
int m = l+(r-l)/2;
for(int i = m; i>=l; --i){
if (i == m){
ret[dep][i] = arr[i];
}else{
ret[dep][i] = Secret(ret[dep][i + 1], arr[i]);
}
}
for (int i = m + 1; i<=r; ++i){
if (i == m + 1){
ret[dep][i] = arr[i];
}else{
ret[dep][i] = Secret(ret[dep][i - 1], arr[i]);
}
}
for (int i = m + 1; i<=r; ++i)mask[i]^=(1 << dep);
init(l,m,dep +1);
init(m+1,r,dep+1);
};
init(0,n-1,0);
}
int Query(int L, int R) {
int k = __builtin_clz(mask[L] ^ mask[R]);
return Secret(ret[k][L], ret[k][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |