Submission #751465

#TimeUsernameProblemLanguageResultExecution timeMemory
751465jmyszka2007Secret (JOI14_secret)C++17
0 / 100
536 ms8388 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int res[1010][1010]; int tab[1010]; int N; void cnt(int l, int r) { if(l > r) { return; } if(l == r) { res[l][l] = tab[l]; return; } int mid = (l + r) / 2; res[mid][mid] = tab[mid]; res[mid][mid - 1] = tab[mid - 1]; for(int i = mid - 2; i >= l; i--) { res[mid][i] = Secret(tab[i], res[mid][i + 1]); } for(int i = mid + 1; i <= r; i++) { res[mid][i] = Secret(res[mid][i - 1], tab[i]); } cnt(l, mid - 1); cnt(mid + 1, r); } void Init(int n, int a[]) { N = n; for(int i = 0; i < n; i++) { tab[i] = a[i]; } cnt(0, n - 1); } int rek(int l, int r, int L, int R) { if(l == r) { return tab[l]; } int mid = (L + R) / 2; if(l <= mid && mid <= r) { return Secret(res[mid][l], res[mid][r]); } if(l > mid) { return rek(l, r, mid + 1, R); } return rek(l, r, L, mid - 1); } int Query(int l, int r) { return rek(l, r, 0, N - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...