#P1963. [NOI2009] 变换序列
[NOI2009] 变换序列
Description
Consider the integers . A transformation sequence maps to , where and . For all , define the distance between and as . Given each , you need to find a transformation sequence that satisfies the requirements. If there are multiple valid sequences, output the lexicographically smallest one.
Note: For two transformation sequences and , if there exists such that for , and , then we say is lexicographically smaller than .
Input Format
The first line contains a positive integer , the length of the sequence. The next line contains integers , where denotes the distance between and .
Output Format
If at least one valid transformation sequence exists, output one line with integers, which is the lexicographically smallest you computed; otherwise output No Answer. Note that adjacent numbers are separated by a single space, and there is no trailing space at the end of the line.
5
1 1 2 2 1
1 2 4 0 3
Hint
- For 30% of the testdata: .
- For 60% of the testdata: .
- For 100% of the testdata: .
Translated by ChatGPT 5
京公网安备 11011102002149号