CF1777F.Comfortably Numb

普及/提高-

通过率:0%

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 lrl \leq r ) is defined as max(al,al+1,,ar)(alal+1ar)\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.

输入格式

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

The first line of each test case contains a single integer nn ( 1n21051 \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 ( 0ai1090 \leq a_i \leq 10^9 ).

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

输出格式

For each test case, print one integer — the maximum numbness over all subarrays of the given array.

输入输出样例

  • 输入#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 34553 \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.

首页