Codeforces Round 832 (Div. 2) |
---|
Finished |
You are given an array $$$a$$$ of $$$n$$$ integers $$$a_1, a_2, a_3, \ldots, a_n$$$.
You have to answer $$$q$$$ independent queries, each consisting of two integers $$$l$$$ and $$$r$$$.
You can find more details about XOR operation here.
The first line contains two integers $$$n$$$ and $$$q$$$ $$$(1 \le n, q \le 2 \cdot 10^5)$$$ — the length of the array $$$a$$$ and the number of queries.
The next line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ $$$(0 \le a_i \lt 2^{30})$$$ — the elements of the array $$$a$$$.
The $$$i$$$-th of the next $$$q$$$ lines contains two integers $$$l_i$$$ and $$$r_i$$$ $$$(1 \le l_i \le r_i \le n)$$$ — the description of the $$$i$$$-th query.
For each query, output a single integer — the answer to that query.
7 6 3 0 3 3 1 2 3 3 4 4 6 3 7 5 6 1 6 2 2
-1 1 1 -1 2 0
In the first query, $$$l = 3, r = 4$$$, subarray = $$$[3, 3]$$$. We can apply operation only to the subarrays of length $$$1$$$, which won't change the array; hence it is impossible to make all elements equal to $$$0$$$.
In the second query, $$$l = 4, r = 6$$$, subarray = $$$[3, 1, 2]$$$. We can choose the whole subarray $$$(L = 4, R = 6)$$$ and replace all elements by their XOR $$$(3 \oplus 1 \oplus 2) = 0$$$, making the subarray $$$[0, 0, 0]$$$.
In the fifth query, $$$l = 1, r = 6$$$, subarray = $$$[3, 0, 3, 3, 1, 2]$$$. We can make the operations as follows:
Name |
---|