QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 128 MB Points totaux : 100

#4446. Link 是只熊

Statistiques

Link 是熊熊学院(BIT)的一位著名熊魔术师,最近他学会了一种新魔法。 给定一个包含 $n$ 个元素 $a_1, \dots, a_n$ 的数组 $a$,Link 可以施展以下魔法: Link 可以选择两个整数 $l, r$,满足 $1 \le l \le r \le n$,并将所有 $a_i$(其中 $l \le i \le r$)替换为 $xor(l, r)$,其中 $xor(l, r)$ 表示区间 $[l, r]$ 内所有元素的按位异或和($\oplus$)。更正式地说,$xor(l, r) = a_l \oplus a_{l+1} \oplus \dots \oplus a_r$。 Link 可以施展任意次(包括零次)该魔法,且可以任意选择 $l, r$。然而,由于 Link 有强迫症(OCD),他希望在操作后所有元素都变得相同。现在,他想知道这个相同值的最大可能值是多少。 此外,Link 发现给定的数组有一个奇怪的性质:总是存在至少一对 $x, y$ ($x \neq y$) 使得 $a_x = a_y$。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 3 \times 10^4$),表示测试用例的数量。 每个测试用例的第一行是一个整数 $n$ ($1 \le n \le 10^5$),表示数组 $a$ 的长度。 每个测试用例的第二行包含 $n$ 个整数,其中第 $i$ 个数表示 $a_i$ ($0 \le a_i \le 10^{15}$)。保证总是存在至少一对 $x, y$ ($x \neq y$) 使得 $a_x = a_y$。 同时保证 $\sum n \le 10^6$。

输出格式

对于每个测试用例,输出一个整数,表示 Link 操作后所有元素相同的那个值的最大值。

样例

输入 1

2
5
10 10 10 10 10
4
1 1 2 1

输出 1

10
3

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.