# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
729944 | jampm | Secret (JOI14_secret) | C++17 | 454 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 "secret.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int const Mxn = 1e3 + 1;
int const LOGN = 13;
ll ST[LOGN][Mxn];
ll A[Mxn];
int n;
void build(int L = 0, int R = n, int depth = 0) {
if (L + 1 == R) {
ST[depth][L] = A[L]; return;
}
int Mid = (L + R)>>1;
for (int i = Mid; i < R; i++) {
ST[depth][i] = (i == Mid) ? A[i] : Secret(ST[depth][i - 1], A[i]);
}
for (int i = Mid - 1; i >= L; i--) {
ST[depth][i] = (i == Mid - 1) ? A[i] : Secret(A[i], ST[depth][i + 1]);
}
build(L, Mid, depth + 1), build(Mid, R, depth + 1);
}
int query(int l, int r, int L = 0, int R = n, int depth = 0) {
//cout << L << " " << R << endl;
if (L + 1 == R) return A[L];
int Mid = (L + R)>>1;
if (l <= Mid && Mid < r) return Secret(ST[depth][l], ST[depth][r]);
if (r < Mid) return query(l, r, L, Mid, depth + 1);
else return query(l, r, Mid, R, depth + 1);
}
void Init(int N, int a[]) {
for (int i = 0; i < N; i++) A[i] = a[i];
n = N; build();
}
int Query(int L, int R) {
return query(L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |