No.2895 Zero XOR Subset
Problem Statement
You are given a sequence of non-negative integers $A = \left( A_1, A_2, \cdots, A_N \right)$ of length $N$.
Determine whether there exists a sequence $B$ satisfying the following conditions, and if one exists, show one example. Here, let $M$ be the length of $B$.
- $1 \leq B_i \leq N$
- $B_i \neq B_j$ whenever $1 \leq i < j \leq M$
- $A_{B_1} \oplus A_{B_2} \oplus \cdots \oplus A_{B_M} = 0$, where for non-negative integers $x,y$, $x \oplus y$ denotes the bitwise XOR of $x$ and $y$.
Input
$N$
$A_1\ \ A_2\ \ \cdots A_N$
- $1 \leq N \leq 2 \times 10^5$
- $0 \leq A_i < 2^{60}$
- All inputs are integers.
Output
If no sequence $B$ satisfying the conditions exists, print -1 followed by a newline.
Otherwise, output in the following format.
$M$If there are multiple valid outputs, print any $1$ of them.
$B_1\ \ B_2\ \ \cdots B_M$
Sample
Sample 1
Input
4
2 0 2 4
Output
2
1 3
This output is valid because $A_{B_1} \oplus A_{B_2} = A_1 \oplus A_3 = 2 \oplus 2 = 0$.
The following output would also be accepted, among others.
1
2
Sample 2
Input
3
2024 20 24
Output
-1
No sequence $B$ satisfying the conditions exists.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
蜜蜂