Submission #704612

#TimeUsernameProblemLanguageResultExecution timeMemory
704612dubabubaSecret (JOI14_secret)C++14
0 / 100
439 ms8372 KiB
#include "secret.h" const int mxn = 1010; int range[mxn][mxn]; int n, a[mxn]; int build(int l, int r, int a[]) { if(l == r) return range[l][r] = a[l]; if(l == r - 1) return range[l][r] = Secret(a[l], a[r]); build(l, (l + r) / 2, a); build((l + r) / 2 + 1, r, a); int m = (l + r) / 2; range[m][m] = a[m]; for(int s = m - 1; s >= l; s--) range[s][m] = Secret(a[s], range[s + 1][m]); m++; range[m][m] = a[m]; for(int e = m + 1; e <= r; e++) range[m][e] = Secret(range[m][e - 1], a[e]); return 0; } void Init(int N, int A[]) { build(0, N - 1, A); n = N; } int Query(int L, int R) { int l = 0, r = n - 1; while(r - l > 1) { int m = (l + r) / 2; if(L == m) return range[L][R]; if(R == m) return range[L][R]; if(L <= m && m < R) return Secret(range[L][m], range[m + 1][R]); if(m < L) l = m; else r = m + 1; } return range[L][R]; }
#Verdict Execution timeMemoryGrader output
Fetching results...