Submission #938912

#TimeUsernameProblemLanguageResultExecution timeMemory
938912PagodePaivaSecret (JOI14_secret)C++17
100 / 100
387 ms4456 KiB
#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 timeMemoryGrader output
Fetching results...