# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
699744 | boyliguanhan | Secret (JOI14_secret) | C++17 | 443 ms | 8356 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"
int calc[1000][1000], n;
void init(int l, int r, int a[]) {
int mid = (l + r) / 2;
calc[mid][mid] = a[mid];
calc[mid + 1][mid + 1] = a[mid + 1];
for (int i = mid + 2; i <= r; i++)
calc[mid + 1][i] = Secret(a[i], calc[mid + 1][i - 1]);
for (int i = mid - 1; i >= l; i--)
calc[mid][i] = Secret(a[i], calc[mid][i + 1]);
if (l < mid)
init(l, mid, a);
if (r > mid + 1)
init(mid + 1, r, a);
}
void Init(int N, int A[]) {
n = N;
init(0, n - 1, A);
}
int Query(int L, int R) {
int l = 0, r = n - 1;
while (l < r) {
int mid = (l + r) / 2;
if (L <= mid && mid < R) return Secret(calc[mid][L], calc[mid + 1][R]);
else if (mid == R) return calc[mid][L];
else if (mid + 1 == L) return calc[mid + 1][R];
else if (mid < L) l = mid + 1;
else r = mid;
}
return calc[l][l];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |