結果
| 問題 |
No.3205 Range Pairwise Xor Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 22:11:41 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 711 ms / 2,000 ms |
| コード長 | 739 bytes |
| コンパイル時間 | 3,445 ms |
| コンパイル使用メモリ | 282,116 KB |
| 実行使用メモリ | 48,512 KB |
| 最終ジャッジ日時 | 2025-07-18 22:12:04 |
| 合計ジャッジ時間 | 11,638 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
#include<atcoder/fenwicktree>
#define int long long
using namespace std;
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,q;cin>>n>>q;
vector<int>a(n);
for(int i=0;i<n;i++)cin>>a[i];
vector<atcoder::fenwick_tree<int>>ft(27,atcoder::fenwick_tree<int>(n));
for(int i=0;i<n;i++){
for(int bit=0;bit<27;bit++){
if(a[i]&(1<<bit))ft[bit].add(i,1);
}
}
while(q--){
int l,r;cin>>l>>r;
l--;r--;
int ans=0;
for(int bit=0;bit<26;bit++){
int zero=0,one=0;
one=ft[bit].sum(l,r+1);
zero=r-l+1-one;
ans+=(1LL<<bit)*zero*one;
}
cout<<ans<<"\n";
}
}