Submission #803751

#TimeUsernameProblemLanguageResultExecution timeMemory
8037518pete8Secret (JOI14_secret)C++14
0 / 100
410 ms4336 KiB
#include<bits/stdc++.h> #include "secret.h" using namespace std; const int mxn=1e3; int ans[11][mxn+10]; int v[mxn+10],mask[mxn+10]; void solve(int l,int r,int lev){ if(l==r)return; int m=(r+l)/2; ans[lev][m]=v[m]; for(int i=m-1;i>=l;i--)ans[lev][i]=Secret(v[i],ans[lev][i+1]); ans[lev][m+1]=v[m+1]; for(int i=m+2;i<=r;i++)ans[lev][i]=Secret(v[i],ans[lev][i-1]); for(int i=m+1;i<=r;i++)mask[i]^=(1ll<<lev); solve(l,m,lev+1); solve(m+1,r,lev+1); } void Init(int N,int A[]){ for(int i=0;i<N;i++)v[i]=A[i]; solve(0,N-1,0); } int Query(int L,int R){ if(L==R)return v[L]; int b=__builtin_ctz(mask[L]^mask[R]); return Secret(ans[b][L],ans[b][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...