# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
916431 | Dec0Dedd | Secret (JOI14_secret) | C++14 | 388 ms | 8564 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;
typedef long long ll;
typedef pair<int, int> pii;
const int N = 1e3+10;
int n, a[N], que[N][N];
void gen(int l, int r) {
if (l == r) {
que[l][l]=a[l];
return;
} int m=(l+r)/2;
gen(l, m), gen(m+1, r);
que[m+1][m+1]=a[m+1];
for (int i=m+2; i<=r; ++i) que[m+1][i]=Secret(que[m+1][i-1], a[i]);
que[m][m]=a[m];
for (int i=m-1; i>=l; --i) que[i][m]=Secret(a[i], que[i+1][m]);
}
void Init(int _n, int ax[]) {
n=_n;
for (int i=1; i<=n; ++i) a[i]=ax[i-1];
gen(1, n);
}
int ans(int l, int r, int ql, int qr) {
if (l == r) return que[l][l];
int m=(l+r)/2;
if (ql <= m && m+1 <= qr) return Secret(que[ql][m], que[m+1][qr]);
if (qr <= m) return ans(l, m, ql, qr);
return ans(m+1, r, ql, qr);
}
int Query(int ql, int qr) {
return ans(1, n, ql+1, qr+1);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |