CF1777F.Comfortably Numb
提高+/省选-
通过率:0%
时间限制:8.00s
内存限制:1024MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an array a consisting of n non-negative integers.
The numbness of a subarray al,al+1,…,ar (for arbitrary l≤r) is defined as $$\max(a_l, a_{l+1}, \ldots, a_r) \oplus (a_l \oplus a_{l+1} \oplus \ldots \oplus a_r),$$ where ⊕ denotes the bitwise XOR operation.
Find the maximum numbness over all subarrays.
给你一个由 n 个非负整数组成的数组 a。
子数组 al,al+1,…,ar(其中任意满足 l≤r)的“麻木值”(numbness)定义为
max(al,al+1,…,ar)⊕(al⊕al+1⊕…⊕ar),
其中 ⊕ 表示按位异或运算。
请找出所有子数组中麻木值的最大值。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤1000). The description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤2⋅105).
The second line of each test case contains n integers a1,a2,…,an (0≤ai≤109).
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤1000)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤2⋅105)。
每个测试用例的第二行包含 n 个整数 a1,a2,…,an(0≤ai≤109)。
保证所有测试用例的 n 值之和不超过 2⋅105。
输出格式
For each test case, print one integer — the maximum numbness over all subarrays of the given array.
对于每个测试用例,输出一个整数——给定数组所有子数组中的最大“numbness”值。
输入输出样例
输入#1
2 5 1 2 3 4 5 3 10 47 52
输出#1
7 47
说明/提示
For the first test case, for the subarray [3,4,5], its maximum value is 5. Hence, its numbness is 3⊕4⊕5⊕5 = 7. This is the maximum possible numbness in this array.
In the second test case the subarray [47,52] provides the maximum numbness.
对于第一个测试用例,子数组 [3,4,5] 的最大值为 5。因此,其“numbness”值为 3⊕4⊕5⊕5=7。这是该数组中可能达到的最大 numbness 值。
在第二个测试用例中,子数组 [47,52] 提供了最大的 numbness 值。
输入解题思路,AI测评打分。不知道怎么写?