LOADING

加载过慢请开启缓存,浏览器默认开启

daily 2

2023/6/29 daily

CF 983B

void solve(){
  int n;
  cin>>n;
  vector dp(n+1,vector<int>(n+1));
  for(int i=1;i<=n;++i){
    cin>>dp[i][i];
  }
  /*
        dp[l][r]=max(dp[l][r],max(dp[l+1][r],dp[l][r-1]))
  */
  for(int len=2;len<=n;++len){
    for(int l=1;l+len-1<=n;++l){
        int r=l+len-1;
        dp[l][r]=dp[l+1][r]^dp[l][r-1];
    }
  }
  for(int len=2;len<=n;++len){
    for(int l=1;l+len-1<=n;++l){
        int r=l+len-1;
        dp[l][r]=max(dp[l][r],max(dp[l+1][r],dp[l][r-1]));
    }
  }
  int q;
  cin>>q;
  while(q--){
    int l,r;
    cin>>l>>r;
    cout<<dp[l][r]<<'\n';
  }
  return;
}

CF 1296E