結果

問題 No.3205 Range Pairwise Xor Query
コンテスト
ユーザー vjudge1
提出日時 2025-11-06 15:08:46
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 304 ms / 2,000 ms
コード長 816 bytes
コンパイル時間 2,891 ms
コンパイル使用メモリ 281,368 KB
実行使用メモリ 53,120 KB
最終ジャッジ日時 2025-11-06 15:08:57
合計ジャッジ時間 10,368 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
$  Problem Name: G_TP_02_G
$  Created: 06 November 2025, Thursday (12:02:21)...
**/

#include<bits/stdc++.h>
using namespace std;

#define nl '\n' 
#define int int64_t

void An$(){
   int n,q;          cin>>n>>q;

   vector<int> a(n+1);
   vector<vector<int>> bt(30,vector<int> (n+1));

   for(int i=1;i<=n;i++){
      cin>>a[i];

      for(int j=0;j<30;j++){
         bt[j][i]=bt[j][i-1];

         if(a[i]&(1LL<<j)){
            bt[j][i]++;
         }
      }
   }

   while(q--){
      int l,r;          cin>>l>>r;

      int ans=0;
      for(int i=0;i<30;i++){
         auto ache=bt[i][r]-bt[i][l-1];
         auto nai=r-l+1-ache;

         ans+=ache*nai*(1LL<<i);
      }

      cout<<ans<<nl;
   }
}

int32_t main(){
   ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

   An$();

   return 0;
}
0