# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938912 | PagodePaiva | Secret (JOI14_secret) | C++17 | 387 ms | 4456 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>
#define N 1010
#define LOGN 11
using namespace std;
int n;
int v[N];
int lt[N][LOGN], rt[N][LOGN];
void prep(int l, int r, int con){
if(l == r) return;
int mid = (l+r)/2;
lt[mid][con] = v[mid];
rt[mid+1][con] = v[mid+1];
for(int i = mid-1;i >= l;i--){
lt[i][con] = Secret(v[i], lt[i+1][con]);
}
for(int i = mid+2;i <= r;i++){
rt[i][con] = Secret(rt[i-1][con], v[i]);
}
prep(l, mid, con+1);
prep(mid+1, r, con+1);
return;
}
int query(int l, int r, int tl = 0, int tr = n-1, int con = 0){
if(tl == tr) return v[tl];
int mid = (tl+tr)/2;
if(l <= mid and mid < r) return Secret(lt[l][con], rt[r][con]);
if(r <= mid) return query(l, r, tl, mid, con+1);
// else return query(l, )
return query(l, r, mid+1, tr, con+1);
}
void Init(int NN, int A[]) {
n = NN;
for(int i = 0;i < n;i++) v[i] = A[i];
prep(0, n-1, 0);
// Secret(0, 1000000000);
}
int Query(int L, int R) {
return query(L, R);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |