# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
720298 | swagchicken | Secret (JOI14_secret) | C++14 | 467 ms | 8252 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 pre[1010][1010] = {};
void process(int L, int R, int A[]) {
if(L == R) return;
int m = (L + R)/2;
pre[m][m] = A[m];
pre[m+1][m+1] = A[m+1];
for(int i = m-1; i >= L; i--) {
pre[m][i] = Secret(A[i], pre[m][i+1]);
}
for(int i = m+2; i <= R; i++) {
pre[m+1][i] = Secret(pre[m+1][i-1], A[i]);
}
process(L, m, A);
process(m+1, R, A);
}
void Init(int N, int A[]) {
n = N;
process(0, N-1, A);
}
int Query(int L, int R) {
int lo = 0, hi = n-1;
while(lo < hi) {
int mid = (lo + hi)/2;
if(L <= mid && R >= mid + 1) {
return Secret(pre[mid][L], pre[mid+1][R]);
} else if(R == mid) {
return pre[mid][L];
}
if(R < mid + 1) {
hi = mid;
} else {
lo = mid + 1;
}
}
return pre[lo][lo];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |