Submission #53155

#TimeUsernameProblemLanguageResultExecution timeMemory
53155okaybody10Secret (JOI14_secret)C++98
0 / 100
629 ms8616 KiB
#include <bits/stdc++.h> #include "secret.h" using namespace std; int n,B[1006],ans[1006][1006]; void init(int s,int e) { int m=(s+e)>>1; ans[m][m]=B[m]; if(s==e) return; ans[m+1][m+1]=B[m+1]; for(int i=m-1;i>=s;i--) ans[i][m]=Secret(ans[i+1][m],B[i]); for(int i=m+2;i<=e;i++) ans[m+1][i]=Secret(ans[m+1][i-1],B[i]); init(s,m),init(m+1,e); } void Init(int N,int A[]) { n=N; for(int i=0;i<N;i++) B[i]=A[i]; init(0,n-1); } int solve(int l,int r,int s,int e) { int m=(s+e)>>1; if(l==r) return B[l]; if(l<=m && m+1<=r) return Secret(ans[l][m],ans[m+1][r]); if(!(m+1<=r)) return solve(l,r,s,m); else return solve(l,r,m+1,e); } int Query(int l,int r) { if(l==r) return B[l]; return solve(l,r,0,n-1); }
#Verdict Execution timeMemoryGrader output
Fetching results...