CF1658D2.388535 (Hard Version)
提高+/省选-
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is the hard version of the problem. The difference in the constraints between both versions are colored below in red. You can make hacks only if all versions of the problem are solved.
Marin and Gojou are playing hide-and-seek with an array.
Gojou initially perform the following steps:
- First, Gojou chooses 2 integers l and r such that l≤r.
- Then, Gojou will make an array a of length r−l+1 which is a permutation of the array [l,l+1,…,r].
- Finally, Gojou chooses a secret integer x and sets ai to ai⊕x for all i (where ⊕ denotes the bitwise XOR operation).
Marin is then given the values of l,r and the final array a. She needs to find the secret integer x to win. Can you help her?
Note that there may be multiple possible x that Gojou could have chosen. Marin can find any possible x that could have resulted in the final value of a.
这是该问题的困难版本。两个版本在约束条件上的区别已在下方用红色标出。仅当该问题的所有版本均被解决时,你才可以进行 hack。
Marin 和 Gojou 正在用一个数组玩捉迷藏。
Gojou 首先执行以下步骤:
- 首先,Gojou 选择两个整数 l 和 r,满足 l≤r。
- 然后,Gojou 构造一个长度为 r−l+1 的数组 a,该数组是数组 [l,l+1,…,r] 的一个排列。
- 最后,Gojou 选择一个秘密整数 x,并对所有 i 将 ai 更新为 ai⊕x(其中 ⊕ 表示按位异或运算)。
随后,Marin 被给出 l、r 和最终的数组 a。她需要找出秘密整数 x 才能获胜。你能帮她吗?
注意:可能存在多个 Gojou 可能选择的 x。Marin 只需找出任意一个能导致最终数组 a 的可能的 x 即可。
输入格式
The first line contains a single integer t (1≤t≤105) — the number of test cases.
In the first line of each test case contains two integers l and r (0≤l≤r<217).
The second line contains r−l+1 space-seperated integers of a1,a2,…,ar−l+1 (0≤ai<217). It is guaranteed that array a is valid.
It is guaranteed that the sum of r−l+1 over all test cases does not exceed 217.
第一行包含一个整数 t(1≤t≤105)—— 表示测试用例的数量。
每个测试用例的第一行包含两个整数 l 和 r(0≤l≤r<217)。
第二行包含 r−l+1 个由空格分隔的整数 a1,a2,…,ar−l+1(0≤ai<217)。保证数组 a 是合法的。
保证所有测试用例中 r−l+1 的总和不超过 217。
输出格式
For each test case print an integer x. If there are multiple answers, print any.
对每个测试用例,输出一个整数 x。如果有多个答案,输出任意一个即可。
输入输出样例
输入#1
3 4 7 3 2 1 0 4 7 4 7 6 5 1 3 0 2 1
输出#1
4 0 3
说明/提示
In the first test case, the original array is [7,6,5,4].
In the second test case, the original array is [4,7,6,5].
In the third test case, the original array is [3,1,2].
在第一个测试用例中,原始数组为 [7,6,5,4]。
在第二个测试用例中,原始数组为 [4,7,6,5]。
在第三个测试用例中,原始数组为 [3,1,2]。
输入解题思路,AI测评打分。不知道怎么写?