# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1055715 | trandangquang | Secret (JOI14_secret) | C++14 | 262 ms | 4692 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"
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define eb emplace_back
#define all(a) (a).begin(), (a).end()
using namespace std;
int n, a[1005], cnt;
vector <int> ops[4005];
//int Secret(int X, int Y) {
// /// program's
// ++cnt;
// return X^Y;
//}
void build(int id=1, int l=0, int r=n-1) {
if(l == r) {
ops[id] = {a[l]};
return;
}
int mid = (l + r) >> 1;
ops[id] = {a[mid]};
FORD(i, mid-1, l) ops[id].eb(Secret(ops[id].back(), a[i]));
reverse(all(ops[id]));
ops[id].eb(a[mid+1]);
FOR(i, mid+2, r) ops[id].eb(Secret(ops[id].back(), a[i]));
build(id<<1, l, mid);
build(id<<1|1, mid+1, r);
}
void Init(int N, int A[]) {
n = N;
FOR(i, 0, N-1) {
a[i] = A[i];
}
build();
}
int get(int L, int R, int id=1, int l=0, int r=n-1) {
int mid = (l+r) >> 1;
if(L <= mid && mid <= R) {
if(L==mid) return ops[id][R-l];
if(R==mid) return ops[id][L-l];
return Secret(ops[id][L-l], ops[id][R-l]);
}
if(R<=mid) return get(L, R, id<<1, l, mid);
return get(L, R, id<<1|1, mid+1, r);
}
int Query(int L, int R) {
return get(L, R);
}
//int main() {
// int b[] = {1,2,3,4,5,6,7,8};
// Init(8, b);
// cout<<cnt<<'\n';
// cout<<Query(2,2)<<'\n';
//}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |