# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703775 | dubabuba | Secret (JOI14_secret) | C++14 | 520 ms | 4368 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"
const int mxn = 2e5 + 10;
int n, a[mxn], sus[mxn * 4];
void build(int id, int tl, int tr) {
if(tl == tr) {
sus[id] = a[tl];
return;
}
int tm = (tl + tr) / 2;
build(id * 2 + 1, tl, tm);
build(id * 2 + 2, tm + 1, tr);
sus[id] = Secret(sus[id * 2 + 1], sus[id * 2 + 2]);
}
int query(int id, int tl, int tr, int l, int r) {
if(tl == l && r == tr) return sus[id];
int tm = (tl + tr) / 2;
if(r <= tm) return query(id * 2 + 1, tl, tm, l, r);
if(tm < l) return query(id * 2 + 2, tm + 1, tr, l, r);
return Secret(query(id * 2 + 1, tl, tm, l, tm), query(id * 2 + 2, tm + 1, tr, tm + 1, r));
}
void Init(int N, int A[]) {
n = N;
for(int i = 0; i < n; i++)
a[i] = A[i];
build(0, 0, N - 1);
}
int Query(int L, int R) {
return query(0, 0, n - 1, L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |