#P10009. XOR Differencing Queries
XOR Differencing Queries
XOR Differencing Queries
Given a sequence \(a_1,a_2,\dots,a_n\). You need to perform \(q\) operations on the sequence. There are two types of operations:
1 l r
: Replace the subarray \(a_l, a_{l+1}, \dots, a_r\) with its XOR differencing. Formally, for each \(i\) such that \(l < i \le r\), compute \[ b_i = a_i \oplus a_{i-1}, \] then update \(a_i = b_i\). Note that \(a_l\) remains unchanged.2 pos
: Query the value of \(a_{pos}\).
After all operations, you must also output the final state of the sequence \(a\).
inputFormat
The input begins with two integers \(n\) and \(q\) where \(n\) is the length of the sequence and \(q\) is the number of operations.
The second line contains \(n\) space-separated integers \(a_1,a_2,\dots,a_n\), representing the initial sequence.
Each of the next \(q\) lines contains an operation in one of the following formats:
1 l r
2 pos
It is guaranteed that the input follows the described format.
outputFormat
For each query operation (type 2
), output the result on a new line, in the order the queries appear.
After processing all \(q\) operations, output the final sequence \(a\) on a single line, with elements separated by a space.
sample
5 4
1 2 3 4 5
1 2 4
2 3
1 1 5
2 5
1
2
1 3 3 6 2
</p>