Submission #946461

#TimeUsernameProblemLanguageResultExecution timeMemory
946461NintsiChkhaidzeSecret (JOI14_secret)C++17
100 / 100
427 ms8372 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; 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(arr[i],val[i + 1][mid]); 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 arr[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...