[Solution] Circular Xor Reversal Codeforces Solution
You have an array of length . Initially, for all . Note that array is zero-indexed.
You want to reverse this array (that is, make equal to for all ). To do this, you can perform the following operation no more than times:
- Select an integer () and replace by .
Here, denotes the bitwise XOR operation.
Your task is to find any sequence of operations that will result in the array being reversed. It can be shown that under the given constraints, a solution always exists.
The first line contains a single integer () — the length of the array .
On the first line print one integer () — the number of operations performed.
On the second line print integers (). Here, should be the integer selected on the -th operation.
Note that you don't need to minimize the number of operations.
In the notes, the elements on which the operations are performed are colored red.
In the first test case, array will change in the following way:
.
In the second test case, array will change in the following way:
No comments:
Post a Comment