# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
881966 | Alan | Secret (JOI14_secret) | C++17 | 381 ms | 8616 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>
using namespace std;
int Secret(int X, int Y);
int ans[1005][1005], N;
void calc (int l, int r) {
if (r-l <= 2) return;
int mid = (l+r)/2;
for (int i = mid-1; i >= l; i--) ans[i][mid] = Secret(i, mid);
for (int i = mid+2; i <= r; i++) ans[mid+1][i] = Secret(mid+1, i);
calc(l, mid);
calc(mid+1, r);
}
void Init (int n, int A[]) {
N = n;
for (int i = 0; i < n; i++) ans[i][i] = A[i];
calc(1, n);
}
int solve (int l, int r, int ql, int qr) {
int mid = (l+r)/2;
if (qr <= mid) return solve(l, mid, ql, qr);
if (mid+1 <= l) return solve(mid+1, r, ql, qr);
return Secret(ans[ql][mid], ans[mid+1][qr]);
}
int Query (int L, int R) {
return solve(1, N, L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |