Codeforces Round 837 (Div. 2)
F
Hossam and Range Minimum Query
Codeforces
2500
原题
← E→
翻译中…

Hossam gives you a sequence of integers $a_1, \, a_2, \, \dots, \, a_n$ of length $n$. Moreover, he will give you $q$ queries of type $(l, \, r)$. For each query, consider the elements $a_l, \, a_{l + 1}, \, \dots, \, a_r$. Hossam wants to know the smallest number in this sequence, such that it occurs in this sequence an odd number of times.

翻译中…

You need to compute the answer for each query before process the next query.

翻译中…

Input

翻译中…

The first line of the input contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$), the length of the sequence.

翻译中…

The second line contains $n$ integers $a_1, \, a_2, \, \dots, \, a_n$ ($1 \le a_i \le 10^9$).

翻译中…

The third line contains one integer $q$ ($1 \le q \le 2 \cdot 10^5$), the number of queries.

翻译中…

Each of the next $q$ lines contains two integers $a$ and $b$ ($0 \le a, \, b \le 2 \cdot 10^9$), the numbers used to encode the queries.

翻译中…

Let $\mathrm{ans}_i$ be the answer on the $i$-th query, and $\mathrm{ans}_0$ be zero. Then $$l_i = a_i \oplus \mathrm{ans}_{i - 1},$$ $$r_i = b_i \oplus \mathrm{ans}_{i - 1},$$ where $l_i, \, r_i$ are parameters of the $i$-th query and $\oplus$ means the bitwise exclusive or operation. It is guaranteed that $1 \le l \le r \le n$.

翻译中…

Output

翻译中…

For each query, print the smallest number that occurs an odd number of times on the given segment of the sequence.

翻译中…

If there is no such number, print $0$.

翻译中…

Note

翻译中…

In the example,

翻译中…

$$l_1 = 1, \, r_1 = 2,$$ $$l_2 = 1, \, r_2 = 3,$$ $$l_3 = 2, \, r_3 = 4,$$ $$l_4 = 1, \, r_4 = 4,$$ $$l_5 = 2, \, r_5 = 2,$$ $$l_6 = 1, \, r_6 = 5.$$

翻译中…

样例

Input #1
5
1 2 1 2 2
6
1 2
0 2
0 6
0 5
2 2
3 7
Output #1
1
2
1
0
2
2
InputCopy OutputCopy
Input #2
10
51 43 69 48 23 52 48 76 19 55
10
1 1
57 57
54 62
20 27
56 56
79 69
16 21
18 30
25 25
62 61
Output #2
51
55
19
48
76
19
23
19
55
19
InputCopy OutputCopy
题目信息
题号
1771F
时间限制
1.5 s
内存限制
256 MB
标签
二分
位运算
数据结构
哈希
概率论
字符串
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。