# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064939 | DeathIsAwe | Secret (JOI14_secret) | C++14 | 356 ms | 8280 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;
int bollocks[1000][1000], divider[129], arr[1000], en;
void solve(int x, int y) {
int mid = (x + y) / 2;
bollocks[mid][mid] = arr[mid]; bollocks[mid + 1][mid + 1] = arr[mid + 1];
for (int i = mid - 1; i >= x; i--) {
bollocks[i][mid] = Secret(arr[i], bollocks[i + 1][mid]);
}
for (int i = mid + 2; i <= y; i++) {
bollocks[mid + 1][i] = Secret(bollocks[mid + 1][i - 1], arr[i]);
}
if (x < mid) {
solve(x, mid);
}
if (y > mid + 1) {
solve(mid + 1, y);
}
}
void Init(int n, int a[]) {
en = n;
for (int i=0;i<n;i++) {
arr[i] = a[i];
}
solve(0, n - 1);
}
int Query(int L, int R) {
if (L == R) {
return bollocks[L][R];
}
int top = en - 1, bottom = 0, mid;
while (true) {
mid = (top + bottom) / 2;
if (L > mid) {
bottom = mid;
} else if (R < mid) {
top = mid;
} else {
break;
}
}
if (R == mid) {
return bollocks[L][R];
} else {
//cout << bollocks[L][mid] << ' ' << bollocks[mid + 1][R] << ' ';
return Secret(bollocks[L][mid], bollocks[mid + 1][R]);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |