# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1053412 | ArthuroWich | Secret (JOI14_secret) | C++17 | 279 ms | 8348 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 n, a[1005], arr[1005][1005];
void calc(int l, int r) {
if (l == r) {
arr[l][l] = a[l];
return;
}
int m = (l+r)/2;
arr[m][m] = a[m];
arr[m+1][m+1] = a[m+1];
for (int i = m-1; i >= l; i--) {
arr[m][i] = Secret(a[i], arr[m][i+1]);
}
for (int i = m+1; i <= r; i++) {
arr[m+1][i] = Secret(a[i], arr[m+1][i-1]);
}
calc(l, m);
calc(m+1, r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < n; i++) {
a[i] = A[i];
}
calc(0, n-1);
}
int Query(int L, int R) {
int l = 0, r = n-1;
while(l < r) {
int m = (l+r)/2;
if (L <= m && m < R) {
return Secret(arr[m][L], arr[m+1][R]);
} else if (R == m) {
return arr[m][L];
} else if (L == m+1) {
return arr[m+1][R];
} else if (R < m) {
r = m;
} else {
l = m+1;
}
}
return arr[l][l];
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |