# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
52559 | suzy | Secret (JOI14_secret) | C++14 | 2330 ms | 36228 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 <map>
#include <utility>
using namespace std;
typedef pair<int, int> ip;
int a[1001], n;
map<ip, int> d;
int qry(int l, int r, int L, int R) {
if (L == R) return a[L];
int mid = (l + r) / 2;
if (R < mid) return qry(l, mid, L, R);
else if (L >= mid) return qry(mid, r, L, R);
else {
return Secret(d[ip(L, mid - 1)], d[ip(mid, R)]);
}
}
int Query(int L, int R) {
return qry(0, n, L, R);
}
void go(int l, int r) {
if (l + 1 == r) return;
int mid = (l + r) / 2;
int cur = a[mid - 1];
for (int i = mid - 2; i >= 0; i--) {
cur = Secret(a[i], cur);
d[ip(i, mid - 1)] = cur;
}
cur = a[mid];
for (int i = mid + 1; i < n; i++) {
cur = Secret(cur, a[i]);
d[ip(mid, i)] = cur;
}
go(l, mid);
go(mid, r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++) {
a[i] = A[i];
d[ip(i, i)] = a[i];
}
go(0, n);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |