A15624 | Hossam and Range Minimum Query
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
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 \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 <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">bitwise exclusive or</a> operation. It is guaranteed that $1 \\le l \\le r \\le n$$$.
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 <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">bitwise exclusive or</a> operation. It is guaranteed that $1 \\le l \\le r \\le n$$$.
输出格式
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$ .
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. $$$$
$$$$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. $$$$
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted