Submission #1053418

#TimeUsernameProblemLanguageResultExecution timeMemory
1053418ArthuroWichSecret (JOI14_secret)C++17
0 / 100
268 ms8284 KiB
#include "secret.h" #include<bits/stdc++.h> using namespace std; int n, a[1005], arr[1005][1005]; void calc(int l, int r) { if (l == r) { arr[l][l] = a[l]; return; } int m = (l+r)/2; arr[m][m] = a[m]; arr[m+1][m+1] = a[m+1]; for (int i = m-1; i >= l; i--) { arr[m][i] = Secret(a[i], arr[m][i+1]); } for (int i = m+1; i <= r; i++) { arr[m+1][i] = Secret(a[i], arr[m+1][i-1]); } calc(l, m); calc(m+1, r); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; i++) { a[i] = A[i]; } calc(0, n-1); } int Query(int L, int R) { int l = 0, r = n-1; while(l < r) { int m = (l+r)/2; if (L <= m && m < R) { return Secret(arr[m][L], arr[m+1][R]); } else if (R == m) { return arr[m][L]; } else if (L == m+1) { return arr[m+1][R]; } else if (m < L) { L = m+1; } else { r = m; } } return arr[l][l]; }
#Verdict Execution timeMemoryGrader output
Fetching results...