Submission #29096

#TimeUsernameProblemLanguageResultExecution timeMemory
29096PrOAhMeTSecret (JOI14_secret)C++14
100 / 100
659 ms9924 KiB
#include "secret.h" #include <bits/stdc++.h> #define mp make_pair #define pb push_back #define pii pair<int,int> #define LL long long #define st first #define nd second #define endl '\n' using namespace std; int a[1001][1001],size; void dac(int l,int r,int v[]) { if(l>r) return; if(l==r) { a[l][l]=v[l]; return; } int md=(l+r)/2; a[md][md]=v[md]; for(int i=md-1;i>=l;--i) { a[i][md]=Secret(v[i],a[i+1][md]); } if(md!=r) { a[md+1][md+1]=v[md+1]; for(int i=md+2;i<=r;++i){ a[md+1][i]=Secret(a[md+1][i-1],v[i]); } } dac(l,md-1,v); dac(md+1,r,v); } int solve(int l,int r,int ll,int rr) { int md=(l+r)/2; if(ll<=md&&rr>=md) { if(rr==md) return a[ll][md]; else return Secret(a[ll][md],a[md+1][rr]); } if(rr<md) return solve(l,md-1,ll,rr); else return solve(md+1,r,ll,rr); } void Init(int N, int A[]) { size=N; dac(0,N-1,A); } int Query(int L, int R) { return solve(0,size-1,L,R); }
#Verdict Execution timeMemoryGrader output
Fetching results...