#P9741. 「KDOI-06-J」翻转与反转
「KDOI-06-J」翻转与反转
Problem Description
Little W has a sequence of length . He will perform operations on this sequence in order.
In the -th operation (), Little W will perform the following two transformations in order:
- Reverse the numbers in the interval by index. Formally, after this transformation, the sequence becomes $a_i,a_{i-1},\ldots,a_{1},a_{i+1},a_{i+2},\ldots,a_n$.
- Flip the numbers in the interval by value. Formally, after this transformation, for any , if then becomes , otherwise becomes .
Little W wants to know the value of each element in the sequence after all operations are finished.
Input Format
Read input from standard input.
The first line contains a positive integer , representing the length of the sequence.
The next line contains integers, representing the sequence . It is guaranteed that or .
Output Format
Write output to standard output.
Output one line with integers, representing the value of each element in the sequence after all operations.
3
1 1 1
0 0 1
8
1 0 1 1 1 0 0 1
0 1 0 1 1 1 1 0
Hint
[Sample Explanation #1]
The changes of sequence are shown in the table below:
| Operation count | Changes of sequence |
|---|---|
[Sample Explanation #2]
The changes of sequence are shown in the table below:
| Operation count | Sequence after the operation |
|---|---|
| - | |
[Sample #3]
See revflip/revflip3.in and revflip/revflip3.ans in the contestant files.
[Sample #4]
See revflip/revflip4.in and revflip/revflip4.ans in the contestant files.
[Constraints]
For all data, it is guaranteed that , and for any , or .
| Test point ID | Special property | |
|---|---|---|
| None | ||
| None |
Translated by ChatGPT 5