Submission #1100935

#TimeUsernameProblemLanguageResultExecution timeMemory
1100935doducanhSecret (JOI14_secret)C++14
100 / 100
313 ms4680 KiB
#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 timeMemoryGrader output
Fetching results...