# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
949749 | Trisanu_Das | Secret (JOI14_secret) | C++17 | 0 ms | 0 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 <bits/stdc++.h>
#include "secret.h"
int memo[1000][1000], n;
int build(int l, int r, int A[]){
int m = (l + r) / 2;
memo[m][m] = A[m];
memo[m + 1][m + 1] = A[m + 1];
for(int i = m + 2; i <= r; i++) memo[m + 1][i] = Secret(memo[m + 1][i - 1], A[i]);
for(int i = m - 1; i >= l; i--) memo[m][i] = Secret(memo[m][i + 1], A[i]);
if(l < m) build(l, m, A);
if(m + 1 < r) build(m + 1, r, A);
}
void Init(int N, int A[]){
n = N;
build(0, n - 1, A);
}
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) Secret(memo[m][L], memo[m + 1][R]);
else if(mid == R) return memo[m][L];
else if(mid < L) l = m + 1;
else r = m;
}
}