# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
99165 | WLZ | Secret (JOI14_secret) | C++17 | 588 ms | 8460 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;
vector< vector<int> > a;
void build(int l, int r, int A[]) {
if (r - l <= 1) {
return;
}
int mid = (l + r) / 2;
for (int i = mid - 1; i >= l; i--) {
a[i][mid] = Secret(A[i], a[i + 1][mid]);
}
for (int i = mid + 2; i <= r; i++) {
a[mid + 1][i] = Secret(a[mid + 1][i - 1], A[i]);
}
build(l, mid, A);
build(mid + 1, r, A);
}
void Init(int N, int A[]) {
a.assign(N, vector<int>(N, -1));
for (int i = 0; i < N; i++) {
a[i][i] = a[i][i] = A[i];
}
build(0, N - 1, A);
}
int Query(int L, int R) {
if (L == R) {
return a[L][R];
}
if (a[L][R] != -1) {
return a[L][R];
}
for (int mid = L; mid < R; mid++) {
if (a[L][mid] != -1 && a[mid + 1][R] != -1) {
return Secret(a[L][mid], a[mid + 1][R]);
}
}
return -1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |