# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1064899 | DeathIsAwe | Secret (JOI14_secret) | C++14 | 322 ms | 12216 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], conquer[1000][1000], arr[1000], en;
bool exist[1000];
void bollocksolve(int x, int y) {
for (int i=x;i<=y;i++) {
bollocks[i][i] = arr[i];
for (int j=i+1;j<=y;j++) {
bollocks[i][j] = Secret(bollocks[i][j - 1], arr[j]);
}
}
}
void solve(int x, int y, int depth) {
int mid = (x + y) / 2; exist[mid] = true;
conquer[mid][mid] = arr[mid]; conquer[mid + 1][mid] = arr[mid + 1];
for (int i = mid - 1; i >= x; i--) {
conquer[i][mid] = Secret(arr[i], conquer[i + 1][mid]);
}
for (int i = mid + 2; i <= y; i++) {
conquer[i][mid] = Secret(conquer[i - 1][mid], arr[i]);
}
if (depth < 7) {
if (x < mid) {
solve(x, mid, depth + 1);
}
if (y > mid + 1) {
solve(mid + 1, y, depth + 1);
}
} else {
if (x < mid) {
bollocksolve(x, mid);
}
if (y > mid + 1) {
bollocksolve(mid + 1, y);
}
}
}
void Init(int n, int a[]) {
en = n;
for (int i=0;i<n;i++) {
arr[i] = a[i];
exist[i] = false;
}
solve(0, n - 1, 1);
}
int Query(int L, int 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;
}
}
//cout << mid << ' ' << exist[mid] << ' ';
if (exist[mid]) {
if (L == mid) {
return conquer[R][L];
} else if (R == mid) {
return conquer[L][R];
}
//cout << conquer[L][mid] << ' ' << conquer[R][mid] << ' ';
return Secret(conquer[L][mid], conquer[R][mid]);
} else {
return bollocks[L][R];
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |