Xor of 3 solution codeforces
You are given a sequenceof length consisting of s and s.
You can perform the following operation on this sequence:
- Pick an index from to (inclusive).
- Change all of bitwise XOR operation , , to simultaneously, where denotes the
Find a sequence of at most operations that changes all elements of to s or report that it’s impossible.We can prove that if there exists a sequence of operations of any length that changes all elements of to s, then there is also such a sequence of length not greater than .
Each test contains multiple test cases. The first line contains the number of test cases( ).
The first line of each test case contains a single integer( ) — the length of .
The second line of each test case containsintegers ( or ) — elements of .
It is guaranteed that the sum ofover all test cases does not exceed .
For each test case, do the following:
- if there is no way of making all the elements of NO“. equal to after performing the above operation some number of times, print “
- otherwise, in the first line print “YES“, in the second line print ( ) — the number of operations that you want to perform on , and in the third line print a sequence ( ) — the indices on which the operation should be applied.
If there are multiple solutions, you may print any.
3 3 0 0 0 5 1 1 1 1 0 4 1 0 0 1
YES 0 YES 2 3 1 NO
In the first example, the sequence contains onlys so we don’t need to change anything.
In the second example, we can transformto and then to by performing the operation on the third element of and then on the first element of .
In the third example, no matter whether we first perform the operation on the first or on the second element ofwe will get , which cannot be transformed to .