# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703004 | BERNARB01 | Secret (JOI14_secret) | C++17 | 468 ms | 8404 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;
const int N = 1003;
int n;
int a[N];
int precalc[N][N];
void PreCalc(int l, int r) {
int y = (l + r) >> 1;
precalc[y][y] = a[y];
for (int i = y - 1; i >= l; i--) {
precalc[i][y] = Secret(a[i], precalc[i + 1][y]);
}
precalc[y + 1][y + 1] = a[y + 1];
for (int i = y + 2; i <= r; i++) {
precalc[y + 1][i] = Secret(precalc[y + 1][i - 1], a[i]);
}
if (l < y) {
PreCalc(l, y);
}
if (y + 1 < r) {
PreCalc(y + 1, r);
}
}
void Init(int N_, int A[]) {
n = N_;
for (int i = 0; i < n; i++) a[i] = A[i];
PreCalc(0, n - 1);
}
int get(int l, int r, int ll, int rr) {
if (ll == rr) {
return a[ll];
}
int y = (l + r) >> 1;
if (rr <= y) {
return get(l, y, ll, rr);
}
if (ll > y) {
return get(y + 1, r, ll, rr);
}
return Secret(precalc[ll][y], precalc[y + 1][rr]);
}
int Query(int ll, int rr) {
return get(0, n - 1, ll, rr);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |