Submission #1145442

#TimeUsernameProblemLanguageResultExecution timeMemory
1145442NewtonabcSecret (JOI14_secret)C++20
0 / 100
332 ms4432 KiB
#include "secret.h" int dp[1010][10]; //ans of i to i+(1<<j)-1 to the right //j=0->7 int arr[1010]; void Init(int N, int A[]) { for(int i=0;i<N;i++) arr[i]=A[i]; for(int i=0;i<N;i++) dp[i][0]=A[i]; for(int i=0;i<N;i++){ for(int j=1;j<=7;j++){ if(i+(1<<j)-1>=N) break; dp[i][j]=Secret(dp[i][j-1],dp[i+(1<<(j-1))][j-1]); } } } int call(int a,int b){ if(a==-1) return b; return Secret(a,b); } int Query(int L, int R) { int ans=arr[L++]; int now=L; while(now+(1<<7)-1<=R){ ans=call(ans,dp[now][7]); now+=(1<<7); } for(int i=7;i>=0;i--){ if(now+(1<<i)-1<=R){ ans=call(ans,dp[now][i]); now+=(1<<i); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...