Submission #34340

#TimeUsernameProblemLanguageResultExecution timeMemory
34340aomeSecret (JOI14_secret)C++14
100 / 100
636 ms9956 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; int n; int f[1005][1005]; int a[1005]; void solve(int l, int r) { if (l > r) return; if (l == r) { f[l][l] = a[l]; return; } int mid = (l + r) / 2; solve(l, mid), solve(mid + 1, r); for (int i = mid - 1; i >= l; --i) { f[i][mid] = Secret(a[i], f[i + 1][mid]); } for (int i = mid + 2; i <= r; ++i) { f[mid + 1][i] = Secret(f[mid + 1][i - 1], a[i]); } } int Query(int l, int r) { for (int i = l; i < r; ++i) { if (f[l][i] != -1 && f[i + 1][r] != -1) { return Secret(f[l][i], f[i + 1][r]); } } return f[l][r]; } void Init(int N, int A[]) { memset(f, -1, sizeof(f)); n = N; for (int i = 0; i < n; ++i) a[i] = A[i]; solve(0, n - 1); }
#Verdict Execution timeMemoryGrader output
Fetching results...