310066: CF1777F. Comfortably Numb

Memory Limit:1024 MB Time Limit:8 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Comfortably Numb

题意翻译

给一个长度为 $n$ 的序列 $a$,对于连续子序列 $a[l \cdots r]$,定义其分数为 $a_l \oplus a_{l+1} \oplus a_{l+2} \oplus \cdots \oplus a_r \oplus \max\{a[l \cdots r]\}$,其中 $\oplus$ 表示异或。 求 $a$ 中所有连续子序列的最大分数。

题目描述

You are given an array $ a $ consisting of $ n $ non-negative integers. The numbness of a subarray $ a_l, a_{l+1}, \ldots, a_r $ (for arbitrary $ l \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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR). Find the maximum numbness over all subarrays.

输入输出格式

输入格式


Each test contains multiple test cases. The first line contains the number of test cases $ t $ ( $ 1 \le t \le 1000 $ ). The description of the test cases follows. The first line of each test case contains a single integer $ n $ ( $ 1 \leq n \leq 2 \cdot 10^5 $ ). The second line of each test case contains $ n $ integers $ a_1, a_2, \ldots, a_n $ ( $ 0 \leq a_i \leq 10^9 $ ). It is guaranteed that the sum of $ n $ over all test cases does not exceed $ 2 \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] $ , its maximum value is $ 5 $ . Hence, its numbness is $ 3 \oplus 4 \oplus 5 \oplus 5 $ = $ 7 $ . This is the maximum possible numbness in this array. In the second test case the subarray $ [47, 52] $ provides the maximum numbness.

Input

题意翻译

给一个长度为 $n$ 的序列 $a$,对于连续子序列 $a[l \cdots r]$,定义其分数为 $a_l \oplus a_{l+1} \oplus a_{l+2} \oplus \cdots \oplus a_r \oplus \max\{a[l \cdots r]\}$,其中 $\oplus$ 表示异或。 求 $a$ 中所有连续子序列的最大分数。

Output

题目大意:
给定一个由非负整数组成的数组 $ a $,其长度为 $ n $。定义一个子数组 $ a_l, a_{l+1}, \ldots, a_r $(对于任意的 $ l \leq r $)的麻木度为 $\max(a_l, a_{l+1}, \ldots, a_r) \oplus (a_l \oplus a_{l+1} \oplus \ldots \oplus a_r)$,其中 $\oplus$ 表示按位异或操作。要求找出所有子数组中的最大麻木度。

输入输出格式:
输入格式:
每个测试包含多个测试用例。第一行包含测试用例的数量 $ t $($ 1 \le t \le 1000 $)。接下来是测试用例的描述。
每个测试用例的第一行包含一个整数 $ n $($ 1 \leq n \leq 2 \cdot 10^5 $)。
每个测试用例的第二行包含 $ n $ 个整数 $ a_1, a_2, \ldots, a_n $($ 0 \leq a_i \leq 10^9 $)。
保证所有测试用例的 $ n $ 之和不超过 $ 2 \cdot 10^5 $。

输出格式:
对于每个测试用例,输出一个整数,表示给定数组所有子数组的最大麻木度。

输入输出样例:
输入样例 #1:
```
2
5
1 2 3 4 5
3
10 47 52
```
输出样例 #1:
```
7
47
```
说明:
在第一个测试用例中,对于子数组 $ [3, 4, 5] $,其最大值为 $ 5 $。因此,其麻木度为 $ 3 \oplus 4 \oplus 5 \oplus 5 $ = $ 7 $。这是该数组中可能的最大麻木度。

在第二个测试用例中,子数组 $ [47, 52] $ 提供了最大的麻木度。题目大意: 给定一个由非负整数组成的数组 $ a $,其长度为 $ n $。定义一个子数组 $ a_l, a_{l+1}, \ldots, a_r $(对于任意的 $ l \leq r $)的麻木度为 $\max(a_l, a_{l+1}, \ldots, a_r) \oplus (a_l \oplus a_{l+1} \oplus \ldots \oplus a_r)$,其中 $\oplus$ 表示按位异或操作。要求找出所有子数组中的最大麻木度。 输入输出格式: 输入格式: 每个测试包含多个测试用例。第一行包含测试用例的数量 $ t $($ 1 \le t \le 1000 $)。接下来是测试用例的描述。 每个测试用例的第一行包含一个整数 $ n $($ 1 \leq n \leq 2 \cdot 10^5 $)。 每个测试用例的第二行包含 $ n $ 个整数 $ a_1, a_2, \ldots, a_n $($ 0 \leq a_i \leq 10^9 $)。 保证所有测试用例的 $ n $ 之和不超过 $ 2 \cdot 10^5 $。 输出格式: 对于每个测试用例,输出一个整数,表示给定数组所有子数组的最大麻木度。 输入输出样例: 输入样例 #1: ``` 2 5 1 2 3 4 5 3 10 47 52 ``` 输出样例 #1: ``` 7 47 ``` 说明: 在第一个测试用例中,对于子数组 $ [3, 4, 5] $,其最大值为 $ 5 $。因此,其麻木度为 $ 3 \oplus 4 \oplus 5 \oplus 5 $ = $ 7 $。这是该数组中可能的最大麻木度。 在第二个测试用例中,子数组 $ [47, 52] $ 提供了最大的麻木度。

加入题单

算法标签: