# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373366 | wind_reaper | Secret (JOI14_secret) | C++17 | 506 ms | 4588 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;
const int INF = 1e9;
const int MXN = 1000;
int st[10][MXN], mask[MXN], a[MXN], n;
void dnc(int l, int r, int lev){
if(l == r)
return;
int mid = (l + r) >> 1;
for(int i = mid; i >= l; --i)
st[lev][i] = Secret(a[i], st[lev][i+1]);
st[lev][mid+1] = a[mid+1];
for(int i = mid+2; i <= r; i++)
st[lev][i] = Secret(st[lev][i-1], a[i]);
for(int i = mid + 1; i <= r; i++)
mask[i] ^= (1 << lev);
dnc(l, mid, lev+1), dnc(mid+1, r, lev+1);
}
void Init(int N, int A[]){
n = N;
for(int i = 0; i < n; i++)
a[i] = A[i];
dnc(0, n-1, 0);
}
int Query(int L, int R){
int level = __builtin_ctz(mask[L]^mask[R]);
return Secret(st[level][L], st[level][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |