XOR
Time limit2sMemory limit512 MB
Maintain an array under range XOR updates and point queries, printing each queried element in order.
- Level
Medium6 of 10
- Topics
- Binary search, Prefix sum, Bit manipulation, Sorting
- Solved
- No attempts yet
Problem
Process two kinds of operations on a single sequence.
- XOR into every element of the interval .
- Print the value of the element at index .
Given the initial sequence and the list of operations, produce the result of every print operation in order.
Input
The first line contains the length of the sequence . ()
The second line contains the elements of the sequence, from index to index in order. Every element is a non-negative integer no larger than .
The third line contains the number of queries . ()
Each of the next lines holds one query and starts with the query kind . If is 1, then , , and follow, and is xored into every element of the interval . (, ) If is 2, then follows, and the current value of the element at index is printed. ()
Output
For every query with equal to 2, print the current value of the element at index on its own line.