CF1771F.Hossam and Range Minimum Query
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Hossam gives you a sequence of integers a1,a2,…,an of length n . Moreover, he will give you q queries of type (l,r) . For each query, consider the elements al,al+1,…,ar . 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.
输入格式
The first line of the input contains one integer n ( 1≤n≤2⋅105 ), the length of the sequence.
The second line contains n integers a1,a2,…,an ( 1≤ai≤109 ).
The third line contains one integer q ( 1≤q≤2⋅105 ), the number of queries.
Each of the next q lines contains two integers a and b ( 0≤a,b≤2⋅109 ), the numbers used to encode the queries.
Let ansi be the answer on the i -th query, and ans0 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 1lellerlen$$.
输出格式
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 .
输入输出样例
输入#1
5 1 2 1 2 2 6 1 2 0 2 0 6 0 5 2 2 3 7
输出#1
1 2 1 0 2 2
输入#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
输出#2
51 55 19 48 76 19 23 19 55 19
说明/提示
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. $$