Submission #803744

#TimeUsernameProblemLanguageResultExecution timeMemory
8037448pete8Secret (JOI14_secret)C++14
0 / 100
404 ms4324 KiB
#include<bits/stdc++.h> #include "secret.h" using namespace std; #define ll long long #define f first #define endl "\n" #define s second #define pii pair<int,int> #define ppii pair<int,pii> #define pb push_back #define fastio ios::sync_with_stdio(false);cin.tie(NULL); using namespace std; const int mxn=1e3; int ans[11][mxn+10]; int v[mxn+10],in[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++)in[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(in[L]^in[R]); return Secret(ans[b][L],ans[b][R]); }
#Verdict Execution timeMemoryGrader output
Fetching results...