# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
946441 | NintsiChkhaidze | Secret (JOI14_secret) | C++17 | 375 ms | 8528 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"
int val[1003][1003],arr[1003],n;
void dnq(int l,int r){
if (l == r) return;
int mid = (l + r)/2;
for (int i = mid + 2; i <= r; i++)
val[mid + 1][i] = Secret(val[mid + 1][i - 1],arr[i]);
for (int i = mid - 1; i >= l; i--)
val[i][mid] = Secret(val[i + 1][mid],arr[i]);
dnq(l,mid);
dnq(mid + 1,r);
}
void Init(int N, int A[]) {
n = N;
for (int i = 0; i < N; i++){
val[i][i] = A[i];
arr[i] = A[i];
}
dnq(0,N - 1);
}
int Query(int L, int R) {
if (L == R) return val[L][L];
int l = 0,r = n - 1;
while (1){
int mid = (l + r)/2;
if (L <= mid && mid < R)
return Secret(val[L][mid],val[mid + 1][R]);
if (R <= mid){
r = mid;
}else{
l = mid + 1;
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |