結果
| 問題 | No.3205 Range Pairwise Xor Query |
| コンテスト | |
| ユーザー |
zawakasu
|
| 提出日時 | 2025-07-18 21:31:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 251 ms / 2,000 ms |
| コード長 | 1,616 bytes |
| 記録 | |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 122,788 KB |
| 実行使用メモリ | 45,448 KB |
| 最終ジャッジ日時 | 2025-07-18 21:31:43 |
| 合計ジャッジ時間 | 5,758 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <tuple>
#include <ranges>
namespace ranges = std::ranges;
namespace views = std::views;
// #include "Src/Number/IntegerDivision.hpp"
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// #include "Src/Algebra/Group/AdditiveGroup.hpp"
// #include "Src/DataStructure/FenwickTree/FenwickTree.hpp"
// #include "Src/DataStructure/SegmentTree/SegmentTree.hpp"
// #include "Src/DataStructure/DisjointSetUnion/DisjointSetUnion.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
int N, Q, A[200020];
int main() {
std::cin.tie(nullptr);
std::cout.tie(nullptr);
std::ios::sync_with_stdio(false);
std::cin >> N >> Q;
std::vector cnt(26, std::vector<int>(N));
for (int i = 0 ; i < N ; i++) {
std::cin >> A[i];
for (int j = 0, k = A[i] ; j < 26 ; j++, k >>= 1) {
cnt[j][i] = k & 1;
}
}
std::vector sum(26, std::vector<int>(N + 1));
for (int i = 0 ; i < 26 ; i++) {
for (int j = 0 ; j < N ; j++) sum[i][j + 1] = sum[i][j] + cnt[i][j];
}
while (Q--) {
int L, R;
std::cin >> L >> R;
L--;
long long ans = 0LL;
for (int i = 0 ; i < 26 ; i++) {
const int z = sum[i][R] - sum[i][L];
const int o = R - L - z;
ans += (1LL << i) * z * o;
}
std::cout << ans << '\n';
}
}
zawakasu