Submission #542650

#TimeUsernameProblemLanguageResultExecution timeMemory
542650new_accSecret (JOI14_secret)C++14
0 / 100
468 ms4572 KiB
#include "secret.h" #include<bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; const int N=1e3+10; const int L=13; ll jj[N][L]; int t[N],n; void dc(int a,int b,int x){ int sr=(a+b)>>1; jj[sr][x]=t[sr]; if(a==b) return; for(int i=sr-1;i>=a;i--) jj[i][x]=Secret(t[i],jj[i+1][x]); for(int i=sr+1;i<=b;i++) jj[i][x]=Secret(jj[i-1][x],t[i]); dc(a,sr,x+1),dc(sr+1,b,x+1); } pair<int,int> zn(int a,int b,int p=1,int k=n,int x=1){ int sr=(p+k)>>1; if(a<=sr and b>=sr) return {x,sr}; if(a<=sr) return zn(a,b,p,sr,x+1); return zn(a,b,sr+1,k,x+1); } void Init(int NN,int A[]){ n=NN; for(int i=1;i<=n;i++) t[i]=A[i-1]; dc(1,n,1); } int Query(int a,int b){ a++,b++; pair<int,int> curr=zn(a,b); if(curr.se==a) return jj[b][curr.fi]; if(curr.se==b) return jj[a][curr.fi]; return Secret(jj[a][curr.fi],jj[b][curr.fi]); }
#Verdict Execution timeMemoryGrader output
Fetching results...