Submission #946441

#TimeUsernameProblemLanguageResultExecution timeMemory
946441NintsiChkhaidzeSecret (JOI14_secret)C++17
0 / 100
375 ms8528 KiB
#include "secret.h" int val[1003][1003],arr[1003],n; void dnq(int l,int r){ if (l == r) return; int mid = (l + r)/2; for (int i = mid + 2; i <= r; i++) val[mid + 1][i] = Secret(val[mid + 1][i - 1],arr[i]); for (int i = mid - 1; i >= l; i--) val[i][mid] = Secret(val[i + 1][mid],arr[i]); dnq(l,mid); dnq(mid + 1,r); } void Init(int N, int A[]) { n = N; for (int i = 0; i < N; i++){ val[i][i] = A[i]; arr[i] = A[i]; } dnq(0,N - 1); } int Query(int L, int R) { if (L == R) return val[L][L]; int l = 0,r = n - 1; while (1){ int mid = (l + r)/2; if (L <= mid && mid < R) return Secret(val[L][mid],val[mid + 1][R]); if (R <= mid){ r = mid; }else{ l = mid + 1; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...