#P12521. [Aboi Round 1] ATRI

[Aboi Round 1] ATRI

题目背景

题目描述

给定一个大小为 nn 的可重集 SS 和一个初始值为 00 的变量 xx,你需要重复执行操作,直到集合中只剩下一个元素。

定义一次操作为:在集合中任意选取两个元素,并在集合中删除这两个元素,同时将这两个元素的按位异或和加入集合中,同时,将 xx 也按位异或上这两个元素的异或和。

请从小到大输出所有操作后 xx 的所有可能值。

输入格式

第一行一个正整数 TT 表示数据组数。

每组数据第一行一个整数 nn

每组数据第二行 nn 个整数,表示 SS 中的元素。

输出格式

每组数据输出一行若干个整数表示答案。

1
5
1 2 3 4 5
1 2 3 4 5 6 7
1
4
1 5 3 8
0 7 10 12 14

提示

TT 为数据组数,ssSS 中的元素,数据范围如下表。

$$\def\arraystretch{1.2} \begin{array}{|c|c|c|c|c|c|} \hline \begin{array}{c} \tt{subtask}\\\hline 1\\\hline 2\\\hline 3\\\hline 4\\\hline 5\\\hline \end{array} & \begin{array}{c} T \le 5 \end{array} & \begin{array}{c} n\\\hline \le 8\\\hline \le 20\\\hline \le 500\\\hline \le 2\times 10^3\\\hline \le 4\times 10^4 \end{array} & \begin{array}{c} s\\\hline <2^{16}\\\hline <2^{16}\\\hline <2^9\\\hline <2^{11}\\\hline <2^{16}\\\hline \end{array} & \begin{array}{c} \tt{pts}\\\hline 10\\\hline 10\\\hline 20\\\hline 30\\\hline 30\\\hline \end{array} & \begin{array}{c} \tt{时间限制}\\\hline 1.00\text{s}\\\hline 1.00\text{s}\\\hline 2.00\text{s}\\\hline 3.00\text{s}\\\hline 5.00\text{s}\\\hline \end{array} \\\hline \end{array} $$