# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1100935 | doducanh | Secret (JOI14_secret) | C++14 | 313 ms | 4680 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"
#define LGN 10
unsigned y[LGN][1 << LGN];
void Init(int N, int A[])
{
for (int s = LGN - 1, l = 1 << (LGN - 1); s >= 0; --s, l >>= 1)
for (int i = 0; i + l < N; i += 2 * l)
{
int mid = i + l;
y[s][mid] = A[mid];
y[s][mid - 1] = A[mid - 1];
for (int j = 1; j < l; ++j)
y[s][mid - j - 1] = Secret(A[mid - j - 1], y[s][mid - j]);
for (int j = 1; j < l && mid + j < N; ++j)
y[s][mid + j] = Secret(y[s][mid + j - 1], A[mid + j]);
}
}
int Query(int L, int R)
{
if (L == R)
return y[0][L];
int i = LGN - 1, a = 0, b = 1 << LGN;
while (i)
{
int mid = (a + b) / 2;
if (R < mid)
b = mid;
else if (L >= mid)
a = mid;
else
break;
--i;
}
return Secret(y[i][L], y[i][R]);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |