#FT0000010. Truy vấn XOR trên đoạn (Range Xor Query)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Truy vấn XOR trên đoạn (Range Xor Query)
Range Xor Query
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
You are given nonnegative integers , indexed from . The bitwise XOR operation, written , produces a at a binary position exactly when one of its operands, but not both, has a there. For example, because .
Process operations in order. Operation 1 x y replaces by ; it is neither ordinary addition nor assignment to .
Operation 2 x y asks for the XOR of every element from through inclusive: . All queries use values reflecting preceding updates.
Input
- Line 1:
n qgives array length and operation count. - Line 2:
A_1 A_2 ... A_ngives the initial values in index order. - Next lines: each line contains one of the following commands, in execution order:
1 x y: replace with .2 x y: query XOR over inclusive interval .
Output
For each 2 x y command, print the requested integer computed from the current state on its own line, in query order. Update commands produce no output.
Subtasks
Subtask 1 (20 points):
- .
- .
- .
- for updates.
- for queries.
Subtask 2 (30 points):
- .
- .
- .
- for updates.
- for queries.
Subtask 3 (50 points):
- .
- .
- .
- for updates.
- for queries.
Examples
Input
3 4
1 2 3
2 1 3
2 2 3
1 2 3
2 2 3
Output
0
1
2
Explanation
There are elements. The initial values are [1, 2, 3].
-
Command 1 —
2 1 3: XOR the values[1, 2, 3]: . Print0. -
Command 2 —
2 2 3: XOR the values[2, 3]: . Print1. -
Command 3 —
1 2 3: Position becomes . The new array is[1, 1, 3]. -
Command 4 —
2 2 3: XOR the values[1, 3]: . Print2.
Collect the answers to output-producing commands in their input order, printing one answer per line.