# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
703007 | NeroZein | Secret (JOI14_secret) | C++17 | 419 ms | 8236 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;
const int N = 1003;
int n;
vector<int> a;
int st[N][N];
void solve (int l, int r) {
if (l == r) {
return;
}
int mid = (l + r) >> 1;
solve(l, mid);
solve(mid+1, r);
st[mid][mid] = a[mid];
for (int i = mid - 1; i >= l; --i) {
st[i][mid] = Secret(a[i], st[i+1][mid]);
}
st[mid+1][mid+1] = a[mid+1];
for (int i = mid+2; i <= r; ++i) {
st[mid+1][i] = Secret(st[mid+1][i-1], a[i]);
}
}
void Init(int N_, int A[]) {
n = N_;
a.resize(n);
for (int i = 0; i < n; i++) a[i] = A[i];
solve(0, n - 1);
}
int get (int l, int r, int s, int e) {
if (s == e) {
return a[s];
}
int mid = (l + r) >> 1;
if (s > mid) {
return get(mid+1, r, s, e);
}
if (e <= mid) {
return get(l, mid, s, e);
}
return Secret(st[s][mid], st[mid+1][e]);
}
int Query(int L, int R) {
return get(0, n-1, L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |