Submission #636521

#TimeUsernameProblemLanguageResultExecution timeMemory
636521JooDdaeSecret (JOI14_secret)C++17
0 / 100
433 ms4736 KiB
#include "secret.h" #include <bits/stdc++.h> using namespace std; #define mid ((l+r) >> 1) int n, a[1010]; vector<int> L[4040], R[4040]; void build(int node = 1, int l = 1, int r = n) { int u = a[mid-1]; L[node].push_back(u); for(int i=mid-2;i>=l;i--) { u = Secret(u, a[i]); L[node].push_back(u); } u = a[mid]; R[node].push_back(u); for(int i=mid+1;i<=r;i++) { u = Secret(u, a[i]); R[node].push_back(u); } if(l == r) return; build(node*2, l, mid), build(node*2+1, mid+1, r); } void Init(int N, int A[]) { n = N; for(int i=1;i<=n;i++) a[i] = A[i-1]; build(); } int find(int nl, int nr, int node = 1, int l = 1, int r = n) { if(nl <= mid && mid <= nr) { if(mid == nl) return R[node][nr-mid]; return Secret(L[node][mid-nl-1], R[node][nr-mid]); } if(nr < mid) return find(nl, nr, node*2, l, mid); return find(nl, nr, node*2+1, mid+1, r); } int Query(int L, int R) { return find(L+1, R+1); }
#Verdict Execution timeMemoryGrader output
Fetching results...