# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1032000 | juicy | Secret (JOI14_secret) | C++17 | 303 ms | 8312 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 <bits/stdc++.h>
#include "secret.h"
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int n;
int a[1000], F[1000][1000];
void dc(int l = 0, int r = n - 1) {
if (l == r) {
return;
}
int md = (l + r) / 2;
F[md][md] = a[md];
F[md + 1][md] = a[md + 1];
for (int i = md - 1; i >= l; --i) {
F[i][md] = Secret(a[i], F[i + 1][md]);
}
for (int i = md + 2; i <= r; ++i) {
F[i][md] = Secret(a[i], F[i - 1][md]);
}
dc(l, md);
dc(md + 1, r);
}
int Query(int L, int R) {
for (int K = L; K < R; ++K) {
if (F[L][K] != -1 && F[R][K] != -1) {
return Secret(F[L][K], F[R][K]);
}
}
return a[L];
}
void Init(int _n, int *A) {
n = _n;
for (int i = 0; i < n; ++i) {
a[i] = A[i];
}
memset(F, -1, sizeof(F));
dc();
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |