CF1777F.Comfortably Numb

提高+/省选-

通过率:0%

时间限制:8.00s

内存限制:1024MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of nn non-negative integers.

The numbness of a subarray al,al+1,…,ara_l, a_{l+1}, \ldots, a_r (for arbitrary l≤rl \leq 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 ⊕\oplus denotes the bitwise XOR operation.

Find the maximum numbness over all subarrays.

给你一个由 nn 个非负整数组成的数组 aa。

子数组 al,al+1,…,ara_l, a_{l+1}, \ldots, a_r(其中任意满足 l≤rl \leq r)的“麻木值”(numbness)定义为

max⁡(al,al+1,…,ar)⊕(al⊕al+1⊕…⊕ar),\max(a_l, a_{l+1}, \ldots, a_r) \oplus (a_l \oplus a_{l+1} \oplus \ldots \oplus a_r),

其中 ⊕\oplus 表示按位异或运算。

请找出所有子数组中麻木值的最大值。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤10001 \le t \le 1000). The description of the test cases follows.

The first line of each test case contains a single integer nn (1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5).

The second line of each test case contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (0≤ai≤1090 \leq a_i \leq 10^9).

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤10001 \le t \le 1000)。随后是各测试用例的描述。

每个测试用例的第一行包含一个整数 nn(1≤n≤2⋅1051 \leq n \leq 2 \cdot 10^5)。

每个测试用例的第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(0≤ai≤1090 \leq a_i \leq 10^9)。

保证所有测试用例的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

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][3, 4, 5], its maximum value is 55. Hence, its numbness is 3⊕4⊕5⊕53 \oplus 4 \oplus 5 \oplus 5 = 77. This is the maximum possible numbness in this array.

In the second test case the subarray [47,52][47, 52] provides the maximum numbness.

对于第一个测试用例,子数组 [3,4,5][3, 4, 5] 的最大值为 55。因此,其“numbness”值为 3⊕4⊕5⊕5=73 \oplus 4 \oplus 5 \oplus 5 = 7。这是该数组中可能达到的最大 numbness 值。

在第二个测试用例中,子数组 [47,52][47, 52] 提供了最大的 numbness 值。

输入解题思路,AI测评打分。不知道怎么写?

首页