結果
| 問題 |
No.3205 Range Pairwise Xor Query
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-09 09:45:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 188 ms / 2,000 ms |
| コード長 | 793 bytes |
| コンパイル時間 | 2,373 ms |
| コンパイル使用メモリ | 198,988 KB |
| 実行使用メモリ | 29,824 KB |
| 最終ジャッジ日時 | 2025-06-09 09:45:31 |
| 合計ジャッジ時間 | 8,283 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void solve()
{
int n, q;
cin >> n >> q;
vector<vector<int>> v(n + 1, vector<int>(26, 0));
for (int i = 0; i < n; i++)
{
int a;
cin >> a;
for (int j = 0; j < 26; j++)
{
v[i + 1][j] = v[i][j];
if (((1 << j) & a) != 0)
v[i + 1][j]++;
}
}
for (int i = 0; i < q; i++)
{
int l, r;
cin >> l >> r;
ll ans = 0;
for (int j = 0; j < 26; j++)
{
ll one = v[r][j] - v[l - 1][j];
ll zero = r - l + 1 - one;
ll base = (1LL << j);
ans += one * zero * base;
}
cout << ans << "\n";
}
}
int main()
{
cin.tie(0)->sync_with_stdio(0);
cout << fixed << setprecision(20);
int CNT = 1;
for (int i = 0; i < CNT; i++)
solve();
}