#P16919. [JLCPC 2026] 古明地恋世界第一
[JLCPC 2026] 古明地恋世界第一
Problem Description
Koishi picked up a positive integer sequence of length on the road, where . Now Koishi computed the prefix maximum sequence of , where denotes the maximum among the first elements of , i.e.
$$b_i = \max\{a_1, a_2, \cdots, a_i\} = \max_{1\le j\le i}\{a_j\}$$After obtaining the two sequences, Koishi mixed them together: define a sequence of length as , and then sorted in non-decreasing order.
Because Koishi is an unconscious girl, she lost the values of and , leaving only the sequence .
Because Koishi is an unconscious girl, she gave you the sequence —the cutest college student of the 21st century—hoping that you can find any valid sequence . There may be multiple valid sequences ; in that case, you only need to output any one of them. There may also be no valid sequence at all; in that case, you need to report that there is no solution.
Input Format
The first line contains an integer , denoting the number of test cases. Then follow test cases, each described as follows:
- The first line contains an integer , the length of sequence .
- The second line contains a sequence of length , where adjacent integers are separated by a single space. It is guaranteed that is non-decreasing, and .
It is guaranteed that .
Output Format
For each test case:
- If there is a solution, output a string
Yeson the first line, and output integers on the second line, separated by single spaces, representing one valid sequence you found. - If there is no solution, output a single line with the string
No.
Yes and No are case-insensitive. For example, Yes, YES, and yEs are all considered affirmative, while No, NO, and nO are all considered negative.
5
3
1 1 2 2 3 3
3
1 1 1 1 2 3
6
1 1 1 1 1 4 4 4 5 5 5 5
5
1 1 1 2 3 4 5 5 5 5
9
2 3 3 4 4 5 8 9 9 9 9 9 9 9 9 9 9 9
Yes
1 2 3
No
Yes
1 1 4 5 1 4
No
Yes
9 9 8 2 4 4 3 5 3
Hint
Translated by ChatGPT 5