# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
59351 | gusfring | Secret (JOI14_secret) | C++14 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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]);
}
}
void build(int root, int lo, int hi){
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);
}