# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
502844 | gozonite | Secret (JOI14_secret) | C++14 | 512 ms | 4412 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 <iostream>
#include <vector>
#include <string>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <deque>
#include <queue>
#include <tuple>
#include <cmath>
#include <cctype>
#include <stack>
#include <cassert>
#include "secret.h"
using namespace std;
using ll = long long;
int dat[11][1000];
int mask[1000];
int a[1000];
void build(int l, int r, int A[], int lev) {
if (l == r) return;
int mid = (l+r)/2;
dat[lev][mid] = A[mid]; dat[lev][mid+1] = A[mid+1];
for (int i = mid-1; i >= l; i--) dat[lev][i] = Secret(A[i], dat[lev][i+1]);
for (int i = mid+2; i <= r; i++) dat[lev][i] = Secret(dat[lev][i-1], A[i]);
for (int i = mid+1; i <= r; i++) mask[i] ^= 1<<lev;
build(l, mid, A, lev+1); build(mid+1, r, A, lev+1);
}
void Init(int N, int A[]) {
build(0, N-1, A, 0);
for (int i = 0; i < N; i++) a[i] = A[i];
}
int Query(int L, int R) {
if (L == R) return a[L];
int lev = __builtin_ctz(mask[L]^mask[R]);
return Secret(dat[lev][L], dat[lev][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |