結果
| 問題 |
No.3205 Range Pairwise Xor Query
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-06 15:39:17 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 247 ms / 2,000 ms |
| コード長 | 1,072 bytes |
| コンパイル時間 | 2,692 ms |
| コンパイル使用メモリ | 281,120 KB |
| 実行使用メモリ | 46,848 KB |
| 最終ジャッジ日時 | 2025-11-06 15:46:36 |
| 合計ジャッジ時間 | 7,735 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define nl "\n"
#define int long long
#define yes cout<<"YES"<< nl;
#define no cout<<"NO"<< nl;
#define pb push_back
#define vi vector<int>
#define si set<int>
#define ip(x) for(auto &it : x) cin>>it
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
// Mohammad Hasibur Rahman
void solve(){
int n, q; cin >> n >> q;
vi v(n + 1);
for (int i = 1; i <= n; i++) cin >> v[i];
int x = 26;
vector<vector<int>> vv(x, vector<int>(n + 1, 0));
for (int i = 0; i < x; i++) {
for (int j = 1; j <= n; j++) {
vv[i][j] = vv[i][j-1] + ((v[j] >> i) & 1);
}
}
while(q--) {
int l, r; cin >> l >> r;
int ans = 0;
for (int i = 0; i < x; i++) {
int a = vv[i][r] - vv[i][l - 1];
int b = (r - l + 1) - a;
ans += a * b * (1LL << i);
}
cout << ans << nl;
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
solve();
}
vjudge1