#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-1;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=-1;
  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 time | Memory | Grader output | 
|---|
| Fetching results... |