# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
412482 | songc | Secret (JOI14_secret) | C++14 | 529 ms | 4372 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], T[20][1010];
void dnc(int d, int s, int e){
if (s == e) return;
int m=s+e>>1;
T[d][m+1] = A[m+1];
for (int i=m+2; i<=e; i++) T[d][i] = Secret(T[d][i-1], A[i]);
T[d][m] = A[m];
for (int i=m-1; i>=s; i--) T[d][i] = Secret(A[i], T[d][i+1]);
dnc(d+1, s, m), dnc(d+1, m+1, e);
}
void Init(int _N, int P[]){
N = _N;
for (int i=0; i<N; i++) A[i] = P[i];
dnc(0, 0, N-1);
}
int qry(int d, int s, int e, int ts, int te){
int m=s+e>>1;
if (ts <= m && m <= te) return Secret(T[d][ts], T[d][te]);
if (te <= m) return qry(d+1, s, m, ts, te);
return qry(d+1, m+1, e, ts, te);
}
int Query(int L, int R){
if (L == R) return A[L];
return qry(0, 0, N-1, L, R);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |