A15982 | Vampiric Powers, anyone?
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
[DIO](https://jojowiki.com/Dio_Brando) knows that the Stardust Crusaders have determined his location and will be coming to fight him. To foil their plans he decides to send out some [Stand](https://jojo.fandom.com/wiki/Stand) users to fight them. Initially, he summoned $n$ Stand users with him, the $i$ -th one having a strength of $a_i$ . Using his vampiric powers, he can do the following as many times as he wishes:
- Let the current number of Stand users be $m$ .
- DIO chooses an index $i$ ( $1 \le i \le m$ ).
- Then he summons a new Stand user, with index $m+1$ and strength given by: $$$$a_{m+1} = a_i \oplus a_{i+1} \oplus \ldots \oplus a_m, $$ <p>where the operator $\\oplus$ denotes the <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">bitwise XOR operation</a>. </p></li><li> Now, the number of Stand users becomes $m+1$$$.
Unfortunately for DIO, by using Hermit Purple's divination powers, the Crusaders know that he is plotting this, and they also know the strengths of the original Stand users. Help the Crusaders find the maximum possible strength of a Stand user among all possible ways that DIO can summon.
- Let the current number of Stand users be $m$ .
- DIO chooses an index $i$ ( $1 \le i \le m$ ).
- Then he summons a new Stand user, with index $m+1$ and strength given by: $$$$a_{m+1} = a_i \oplus a_{i+1} \oplus \ldots \oplus a_m, $$ <p>where the operator $\\oplus$ denotes the <a href="https://en.wikipedia.org/wiki/Bitwise_operation#XOR">bitwise XOR operation</a>. </p></li><li> Now, the number of Stand users becomes $m+1$$$.
Unfortunately for DIO, by using Hermit Purple's divination powers, the Crusaders know that he is plotting this, and they also know the strengths of the original Stand users. Help the Crusaders find the maximum possible strength of a Stand user among all possible ways that DIO can summon.
输入格式
Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 10\,000$ ). The description of the test cases follows.
The first line of each test case contains a single integer $n$ ( $1 \le n \le 10^5$ ) – the number of Stand users initially summoned.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \le a_i < 2^8$ ) – the strength of each Stand user.
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
The first line of each test case contains a single integer $n$ ( $1 \le n \le 10^5$ ) – the number of Stand users initially summoned.
The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ ( $0 \le a_i < 2^8$ ) – the strength of each Stand user.
It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$ .
输出格式
For each test case, output a single integer, maximum strength of a Stand user among all possible ways that DIO can summon.
输入输出样例
输入 #1
3 4 0 2 5 1 3 1 2 3 5 8 2 4 12 1
输出 #1
7 3 14
In the first test case, one of the ways to add new Stand users is as follows:
- Choose $i=n$ . Now, $a$ becomes $[0,2,5,1,1]$ .
- Choose $i=1$ . Now, $a$ becomes $[0,2,5,1,1,7]$ . $7$ is the maximum strength of a Stand user DIO can summon.
In the second test case, DIO does not need to add more Stand users because $3$ is the maximum strength of a Stand user DIO can summon.
- Choose $i=n$ . Now, $a$ becomes $[0,2,5,1,1]$ .
- Choose $i=1$ . Now, $a$ becomes $[0,2,5,1,1,7]$ . $7$ is the maximum strength of a Stand user DIO can summon.
In the second test case, DIO does not need to add more Stand users because $3$ is the maximum strength of a Stand user DIO can summon.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted