Submission #573926

#TimeUsernameProblemLanguageResultExecution timeMemory
573926VanillaSecret (JOI14_secret)C++17
0 / 100
456 ms12344 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; const int maxn = 1001; int pref [maxn][maxn]; int sg [maxn][maxn]; int a[maxn]; int n; void build (int l, int r) { int mid = (l + r) / 2; if (l >= r) return; for (int i = mid; i >= l; i--){ for (int j = mid; j <= r; j++){ sg[i][j] = mid; } } for (int i = mid + 2; i <= r; i++){ pref[mid + 1][i] = Secret(pref[mid + 1][i-1], a[i]); } for (int i = mid - 1; i >= l; i--){ pref[i][mid] = Secret(pref[i + 1][mid], a[i]); } build (l, mid); build (mid + 1, r); } void Init(int N, int A[]) { n = N; for (int i = 0; i < n; i++){ a[i] = A[i]; pref[i][i] = a[i]; } build(0, n - 1); } int Query(int L, int R) { int mid = sg[L][R]; if (pref[L][R]) return pref[L][R]; return Secret(pref[L][mid], pref[mid + 1][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...