結果
問題 |
No.3205 Range Pairwise Xor Query
|
ユーザー |
![]() |
提出日時 | 2025-07-29 17:20:53 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 265 ms / 2,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 1,961 ms |
コンパイル使用メモリ | 198,612 KB |
実行使用メモリ | 25,088 KB |
最終ジャッジ日時 | 2025-07-29 17:21:01 |
合計ジャッジ時間 | 7,562 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios::sync_with_stdio(false); std::cin.tie(nullptr); } int main() { fast_io(); int n, q; cin >> n >> q; vector<int> a(n); vector<vector<int>> cum(26, vector<int>(n + 1, 0)); for (int i = 0; i < n; i++) { cin >> a[i]; for (int j = 0; j < 26; j++) { cum[j][i + 1] = cum[j][i] + ((a[i] >> j) & 1); } } for (; q--;) { int l, r; cin >> l >> r; l--; long long ans = 0; for (int j = 0; j < 26; j++) { int cnt_1 = cum[j][r] - cum[j][l]; int cnt_0 = (r - l) - cnt_1; ans += (1LL << j) * cnt_1 * cnt_0; } cout << ans << "\n"; } }