KiaKio 与能量区间AI (CI翻译)
Kia and Kio found a glowing array $a_1, a_2, \ldots, a_n$ inside a crystal terminal in the ruins of an ancient digital kingdom.
Kia 和 Kio 在古老数字王国遗迹的一台水晶终端中,发现了一个发光数组 $a_1, a_2, \ldots, a_n$。AI (CI翻译)
The terminal works like this. Kia picks a segment of the array: any two indices $l$ and $r$ with $l \lt r$ (so the segment always has at least two elements). Kio then finds the strongest energy in that segment, $m = \max\left(a_l, a_{l+1}, \ldots, a_r\right)$, and the terminal masks every element of the segment with $m$ (bitwise AND), then fuses the results together (bitwise XOR):
这台终端的工作方式如下:Kia 选取数组中的一个区间,即任意两个满足 $l \lt r$ 的下标 $l$ 和 $r$(因此区间至少包含两个元素)。接着,Kio 找出该区间中的最强能量 $m = \max\left(a_l, a_{l+1}, \ldots, a_r\right)$,终端将区间内的每个元素与 $m$ 进行按位与运算,再将结果按位异或起来:AI (CI翻译)
$$ (a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m). $$
$$ (a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m). $$AI (CI翻译)
That number is the energy released.
这个数就是释放出的能量。AI (CI翻译)
Kia wants the strongest possible blast. Over all valid segments $(l, r)$, what is the largest energy the terminal can produce?
Kia 想要制造尽可能强烈的爆发。在所有合法区间 $(l, r)$ 中,终端能够产生的最大能量是多少?AI (CI翻译)
Here, $\&$ denotes the bitwise AND operation, and $\oplus$ denotes the bitwise XOR operation.
Input
输入格式
AI (CI翻译)Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.
每个输入文件包含多组测试用例。第一行包含测试用例数量 $t$($1 \le t \le 10^4$)。接下来是各测试用例的描述。AI (CI翻译)
The first line of each test case contains a single integer $n$ ($2 \le n \le 2\cdot10^5$) — the size of the array.
每组测试用例的第一行包含一个整数 $n$($2 \le n \le 2\cdot10^5$)——数组的长度。AI (CI翻译)
The second line contains $n$ integers $a_1,a_2,\ldots,a_n$ ($0 \le a_i \lt 2^{18}$).
第二行包含 $n$ 个整数 $a_1,a_2,\ldots,a_n$($0 \le a_i \lt 2^{18}$)。AI (CI翻译)
It is guaranteed that the sum of $n$ over all test cases does not exceed $2\cdot10^5$.
保证所有测试用例的 $n$ 之和不超过 $2\cdot10^5$。AI (CI翻译)
Output
输出格式
AI (CI翻译)For each test case, print a single integer — the maximum possible value of
对于每组测试用例,输出一个整数——在所有满足 $l \lt r$ 的下标对 $(l,r)$ 中,表达式AI (CI翻译)
$$ (a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m) $$
$$ (a_l \,\&\, m)\oplus(a_{l+1} \,\&\, m)\oplus\cdots\oplus(a_r \,\&\, m) $$AI (CI翻译)
among all pairs $(l,r)$ satisfying $l \lt r$.
所能取得的最大值。AI (CI翻译)
Note
说明
AI (CI翻译)In the first test case, one optimal interval is $l=1$ and $r=2$. The maximum element in this interval is $m=7$.
在第一组测试用例中,一个最优区间是 $l=1$ 且 $r=2$。该区间内的最大元素为 $m=7$。AI (CI翻译)
The value becomes $(1\,\& \,7)\oplus(7\,\&\,7) = 6$.
此时结果为 $(1\,\& \,7)\oplus(7\,\&\,7) = 6$。AI (CI翻译)
样例
4
5
1 7 3 7 2
3
3 1 2
5
1 5 2 3 4
4
3 5 2 6
6
2
5
5
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。