Problem - 1747D - Codeforces
Problem - 1747D - Codeforces
|
stdfloat | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP
You have to answer q independent queries, each consisting of two integers l and r .
→ Clone Contest to Mashup
Consider the subarray a[l : r] = [al , al+1 , … , ar ] . You can apply the following
operation to the subarray any number of times (possibly zero)-
→ Submit?
1. Choose two integers L , R such that l ≤ L ≤ R ≤ r and R − L + 1 is odd.
2. Replace each element in the subarray from L to R with the XOR of the elements in Language: GNU G++20 13.2 (64 bit, winlibs)
You can find more details about XOR operation here. → Contest materials
The next line contains n integers a1 , a2 , … , an (0 ≤ ai < 230 ) — the elements of the
array a.
The i -th of the next q lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n) — the
description of the i -th query.
Output
For each query, output a single integer — the answer to that query.
Example
input Copy
7 6
3 0 3 3 1 2 3
3 4
4 6
3 7
5 6
1 6
2 2
output Copy
-1
1
1
-1
2
0
Note
https://mirror.codeforces.com/problemset/problem/1747/D 1/2
5/22/24, 12:09 PM Problem - 1747D - Codeforces
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 ⊕ 1 ⊕ 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:
Supported by
https://mirror.codeforces.com/problemset/problem/1747/D 2/2