# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1069472 | Requiem | Secret (JOI14_secret) | C++17 | 305 ms | 4436 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 "secret.h"
#include<bits/stdc++.h>
#define ll long long
#define FOR(i, a, b) for(int i = a; i <= b;i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
using namespace std;
const int MAXN = 1002;
int P[20][MAXN], mask[MAXN], a[MAXN];
void DnC(int l, int r, int lev){
if (l == r){
return;
}
int mid = (l + r) >> 1;
P[lev][mid] = a[mid];
P[lev][mid + 1] = a[mid + 1];
FORD(i, mid - 1, l){
P[lev][i] = Secret(P[lev][i + 1], a[i]);
}
FOR(i, mid + 2, r){
P[lev][i] = Secret(P[lev][i - 1], a[i]);
}
FOR(i, mid + 1, r) mask[i] ^= (1LL << lev);
DnC(l, mid, lev + 1);
DnC(mid + 1, r, lev + 1);
}
void Init(int N, int A[]) {
FOR(i, 0, N - 1){
a[i] = A[i];
}
DnC(0, N - 1, 0);
}
int Query(int L, int R) {
if (L == R) return a[L];
else{
int bit = __builtin_ctz(mask[L] ^ mask[R]);
return Secret(P[bit][L], P[bit][R]);
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |