CF1582F1.Korney Korneevich and XOR (easy version)
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
This is an easier version of the problem with smaller constraints.
Korney Korneevich dag up an array a of length n . Korney Korneevich has recently read about the operation bitwise XOR, so he wished to experiment with it. For this purpose, he decided to find all integers x≥0 such that there exists an increasing subsequence of the array a , in which the bitwise XOR of numbers is equal to x .
It didn't take a long time for Korney Korneevich to find all such x , and he wants to check his result. That's why he asked you to solve this problem!
A sequence s is a subsequence of a sequence b if s can be obtained from b by deletion of several (possibly, zero or all) elements.
A sequence s1,s2,…,sm is called increasing if s1<s2<…<sm .
输入格式
The first line contains a single integer n ( 1≤n≤105 ).
The second line contains n integers a1,a2,…,an ( 0≤ai≤500 ) — the elements of the array a .
输出格式
In the first line print a single integer k — the number of found x values.
In the second line print k integers in increasing order x1,x2,…xk ( 0≤x1<…<xk ) — found x values.
输入输出样例
输入#1
4 4 2 2 4
输出#1
4 0 2 4 6
输入#2
8 1 0 1 7 12 5 3 2
输出#2
12 0 1 2 3 4 5 6 7 10 11 12 13
说明/提示
In the first test case:
- To get value x=0 it is possible to choose and empty subsequence
- To get value x=2 it is possible to choose a subsequence [2]
- To get value x=4 it is possible to choose a subsequence [4]
- To get value x=6 it is possible to choose a subsequence [2,4]