# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548159 | Alex_tz307 | Secret (JOI14_secret) | C++17 | 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 <bits/stdc++.h>
#include "secret.h"
using namespace std;
const int kN = 1e3;
const int kLog = 16;
int n, a[kN], dp[kN][kLog];
int Secret(int x, int y) {
return 0;
}
void solve(int l, int r, int level) {
if (l == r) {
return;
}
int mid = (l + r) / 2;
dp[mid][level] = a[mid];
dp[mid + 1][level] = a[mid + 1];
for (int i = mid - 1; i >= l; --i) {
dp[i][level] = Secret(dp[i + 1][level], a[i]);
}
for (int i = mid + 2; i <= r; ++i) {
dp[i][level] = Secret(dp[i - 1][level], a[i]);
}
solve(l, mid, level + 1);
solve(mid + 1, r, level + 1);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; ++i) {
a[i] = A[i];
}
solve(0, n - 1, 0);
}
int Query(int l, int r) {
if (l == r) {
return a[l];
}
int st = 0, dr = n - 1, level = 0;
while (st <= dr) {
int mid = (st + dr) / 2;
if (l <= mid && mid < r) {
return Secret(dp[l][level], dp[r][level]);
}
if (mid < l) {
st = mid + 1;
} else {
dr = mid;
}
level += 1;
}
}