luogu#P4789. [BalkanOI 2018] Zalmoxis
[BalkanOI 2018] Zalmoxis
Problem Description
Translated from BalkanOI 2018 Day 2 T3 “Zalmoxis”.
“ZalPunch” is a way to modify a sequence. Each time you perform a ZalPunch, you can take any non-negative integer in the sequence and replace it in place with two .
- Correct example: ;
- Correct example: ;
- Wrong example: (the first is not in the original position).
Starting from the sequence , all sequences that can be obtained by applying ZalPunch any number of times are called “ZalSequence” (including ).
You are given a sequence with elements. Insert numbers into it (not performing ZalPunch times) so that it becomes a ZalSequence. It is guaranteed that a solution exists.
Input Format
The first line contains two integers .
The second line contains integers, representing the sequence .
Output Format
Output integers, representing the new sequence.
5 1
29 27 25 25 28
29 27 25 25 26 28
1 5
29
29 28 27 26 25 25
Hint
Sample Explanation 1
.
Sample Explanation 2
.
For of the testdata, .
For all testdata, .
Thanks to Planet6174 for providing the translation.
Thanks to @tiger2005 for providing the SPJ.
Translated by ChatGPT 5