結果
問題 |
No.3205 Range Pairwise Xor Query
|
ユーザー |
|
提出日時 | 2025-07-18 22:15:30 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 661 ms / 2,000 ms |
コード長 | 659 bytes |
コンパイル時間 | 3,185 ms |
コンパイル使用メモリ | 279,480 KB |
実行使用メモリ | 25,216 KB |
最終ジャッジ日時 | 2025-07-18 22:15:43 |
合計ジャッジ時間 | 11,503 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 20 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) using namespace std; using ll = long long; int main() { int n, q; cin >> n >> q; vector<int> a(n); rep(i, n) cin >> a[i]; int m = 26; vector s(m, vector<int>(n+1)); rep(k, m)rep(i, n) { s[k][i+1] = s[k][i] + (a[i]>>k&1); } rep(qi, q) { int l, r; cin >> l >> r; --l; ll ans = 0; int w = r-l; rep(k, m) { int c1 = s[k][r] - s[k][l]; int c0 = w-c1; ans += 1ll*c0*c1<<k; } cout << ans << '\n'; } return 0; }