Skip to content

Commit 4134323

Browse files
committed
add RXorQ
1 parent ab413bb commit 4134323

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

cpp/segtree.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,13 @@ using RSumQ = StaticSegTree<S, std::plus<S>, segtree::Zero<S>>;
353353
*/
354354
template <typename S>
355355
using RProdQ = StaticSegTree<S, std::multiplies<S>, segtree::One<S>>;
356+
/**
357+
* @brief RangeXorQuery
358+
*
359+
* @tparam S 型
360+
*/
361+
template <typename S>
362+
using RXorQ = StaticSegTree<S, std::bit_xor<S>, segtree::Zero<S>>;
356363
/**
357364
* @brief RangeGcdQuery
358365
*

test/atcoder-abc185-f.text.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#define PROBLEM "https://atcoder.jp/contests/abc185/tasks/abc185_f"
2+
3+
#include <iostream>
4+
5+
#include "../cpp/segtree.hpp"
6+
7+
int main(void) {
8+
int N, Q;
9+
std::cin >> N >> Q;
10+
std::vector<int> A(N);
11+
for (int& a : A) {
12+
std::cin >> a;
13+
}
14+
StaticSegTree<int, std::bit_xor<int>, segtree::Zero<int>> seg(A);
15+
while (Q--) {
16+
int T, X, Y;
17+
std::cin >> T >> X >> Y;
18+
if (T == 1) {
19+
seg.apply(X - 1, Y);
20+
} else {
21+
int ans;
22+
ans = seg.prod(X - 1, Y);
23+
std::cout << ans << std::endl;
24+
}
25+
}
26+
}

0 commit comments

Comments
 (0)