제출 #699744

#제출 시각아이디문제언어결과실행 시간메모리
699744boyliguanhan비밀 (JOI14_secret)C++17
0 / 100
443 ms8356 KiB
#include "secret.h" int calc[1000][1000], n; void init(int l, int r, int a[]) { int mid = (l + r) / 2; calc[mid][mid] = a[mid]; calc[mid + 1][mid + 1] = a[mid + 1]; for (int i = mid + 2; i <= r; i++) calc[mid + 1][i] = Secret(a[i], calc[mid + 1][i - 1]); for (int i = mid - 1; i >= l; i--) calc[mid][i] = Secret(a[i], calc[mid][i + 1]); if (l < mid) init(l, mid, a); if (r > mid + 1) init(mid + 1, r, a); } void Init(int N, int A[]) { n = N; init(0, n - 1, A); } int Query(int L, int R) { int l = 0, r = n - 1; while (l < r) { int mid = (l + r) / 2; if (L <= mid && mid < R) return Secret(calc[mid][L], calc[mid + 1][R]); else if (mid == R) return calc[mid][L]; else if (mid + 1 == L) return calc[mid + 1][R]; else if (mid < L) l = mid + 1; else r = mid; } return calc[l][l]; }
#Verdict Execution timeMemoryGrader output
Fetching results...