# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
652559 | rsjw | Secret (JOI14_secret) | C++17 | 499 ms | 4340 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 n;
int a[1010];
int B[1010];
int f[10][1010];
void divi(int l = 1, int r = n, int rt = 0) {
if (l == r || l + 1 == r)
return;
int m = (l + r) / 2, i;
f[rt][m] = a[m];
f[rt][m + 1] = a[m + 1];
for (i = m - 1; i >= l; i--)
f[rt][i] = Secret(a[i], f[rt][i + 1]);
for (i = m + 2; i <= r; i++)
f[rt][i] = Secret(f[rt][i - 1], a[i]);
divi(l, m, rt + 1);
divi(m + 1, r, rt + 1);
}
void Init(int N, int A[]) {
int i;
n = N;
for (i = 0; i < N; i++)
B[i] = A[i];
for (int i = 1; i <= n; i++)
a[i] = A[i - 1];
divi();
}
int dS(int L, int R, int l = 1, int r = n, int rt = 0) {
int m = (l + r) / 2, i;
if (R <= m)
return dS(L, R, l, m, rt + 1);
if (L > m)
return dS(L, R, m + 1, r, rt + 1);
return rt;
}
int Query(int L, int R) {
if (L == R)
return B[L];
if (L + 1 == R)
return Secret(B[L], B[L + 1]);
L++, R++;
int rt = dS(L, R);
return Secret(f[rt][L], f[rt][R]);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |