結果
| 問題 |
No.3205 Range Pairwise Xor Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-07-18 21:41:27 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 247 ms / 2,000 ms |
| コード長 | 526 bytes |
| コンパイル時間 | 3,293 ms |
| コンパイル使用メモリ | 275,952 KB |
| 実行使用メモリ | 25,184 KB |
| 最終ジャッジ日時 | 2025-07-18 21:41:35 |
| 合計ジャッジ時間 | 7,201 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
using ll=long long;
constexpr int M=26;
int cum[M][2<<17];
int N,Q,A[2<<17];
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>N>>Q;
rep(i,N)cin>>A[i];
rep(i,M)rep(j,N){
cum[i][j+1]+=cum[i][j];
if(A[j]&(1<<i))++cum[i][j+1];
}
rep(i,Q){
int L,R;cin>>L>>R,--L;
ll ans=0;
rep(j,26){
ll ones=cum[j][R]-cum[j][L];
ll zeros=R-L-ones;
ans+=ones*zeros*(1<<j);
}
cout<<ans<<'\n';
}
}