結果
問題 |
No.3205 Range Pairwise Xor Query
|
ユーザー |
![]() |
提出日時 | 2025-08-09 18:26:10 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 336 ms / 2,000 ms |
コード長 | 835 bytes |
コンパイル時間 | 2,830 ms |
コンパイル使用メモリ | 281,296 KB |
実行使用メモリ | 87,636 KB |
最終ジャッジ日時 | 2025-08-09 18:26:20 |
合計ジャッジ時間 | 9,788 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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++) #define rrep(i,n) for(int i=(int)(n-1);i>=0;i--) #define ALL(v) v.begin(),v.end() #define RALL(v) v.rbegin(),v.rend() template <class T> using V=vector<T>; template <class T> using VV=V<V<T>>; using u128=__int128_t; using ll=long long; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n,q; cin>>n>>q; V<ll> A(n); rep(i,n) cin>>A[i]; VV<ll> B(26,V<ll>(n)),S(26,V<ll>(n+1)); rep(i,n){ rep(j,26){ if((A[i]&(1<<j))) B[j][i]=1; } } rep(j,26){ rep(i,n) S[j][i+1]=S[j][i]+B[j][i]; } while(q--){ int l,r; cin>>l>>r; l--; ll ans=0; rep(j,26){ ll c1=S[j][r]-S[j][l]; ll c0=r-l-c1; ans+=c0*c1*(1<<j); } cout<<ans<<'\n'; } return 0; }