Submission #661527

#TimeUsernameProblemLanguageResultExecution timeMemory
661527rxlfd314Secret (JOI14_secret)C++17
0 / 100
425 ms8308 KiB
#include "secret.h" constexpr int mxN = 1005; int N, pref[mxN][mxN]; void precompute(int l, int r, int A[]) { if (l == r) return; int mid = l + r >> 1; pref[mid][mid] = A[mid]; pref[mid+1][mid+1] = A[mid+1]; for (int i = mid - 1; i >= l; i--) { pref[mid][i] = Secret(pref[mid][i+1], A[i]); } for (int i = mid + 2; i <= r; i++) { pref[mid+1][i] = Secret(pref[mid+1][i-1], A[i]); } precompute(l, mid, A); precompute(mid + 1, r, A); } void Init(int n, int A[]) { N = n; precompute(0, N - 1, A); } int Query(int l, int r) { int lo = 0, hi = N - 1; while (lo < hi) { int mid = lo + hi >> 1; if (l <= mid && mid < r) { return Secret(pref[mid][l], pref[mid+1][r]); } if (r == mid) { return pref[mid][l]; } if (mid < l) { lo = mid + 1; } else { hi = mid; } } return pref[lo][lo]; }

Compilation message (stderr)

secret.cpp: In function 'void precompute(int, int, int*)':
secret.cpp:6:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    6 |  int mid = l + r >> 1;
      |            ~~^~~
secret.cpp: In function 'int Query(int, int)':
secret.cpp:25:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   25 |   int mid = lo + hi >> 1;
      |             ~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...