#P9345. 夕阳西下几时回
夕阳西下几时回
Background
As the sun sets behind the mountains, the last ray of afterglow gradually fades away; the beautiful evening clouds eventually turn into the dark night. In this scene, waves of homesickness rise in one’s heart again and again. For a traveler far from home, even if they do not die in a foreign land, when can they return?
Problem Description
The sunset can be viewed as a graph consisting of different colors. The -th color is , where is a permutation of length .
Define the homesickness value of a permutation as follows:
- For all , let . In particular, we define .
- The homesickness value of permutation is the number of distinct elements in the sequence .
Determine whether there exists a permutation of length whose homesickness value is . If it exists, output any such permutation.
Input Format
This problem contains multiple test cases.
The first line contains a positive integer , representing the number of test cases.
For each test case, one line contains two integers .
Output Format
For each test case:
- If no such permutation exists, output one line with the string
No. - Otherwise, output one line with the string
Yes, then output one line with positive integers , representing the permutation you found.
The checker ignores the case of the strings. For example, YES, yEs, and yes are all considered to indicate that an answer exists.
3
7 1
6 5
11 4
Yes
1 2 3 4 5 6 7
No
Yes
1 11 9 3 6 7 8 2 5 10 4
Hint
[Hint]
A permutation of length is an array in which every positive integer from to appears exactly once. For example, is a permutation of length , while is not a permutation.
[Sample 1 Explanation]
- For the first test case, , so the homesickness value of is .
- For the second test case, it can be proven that no such sequence exists.
- For the third test case, , which contains distinct elements — and — so the homesickness value of is .
[Constraints and Notes]
This problem uses bundled tests.
- Subtask 1 (4 points): , .
- Subtask 2 (5 points): .
- Subtask 3 (13 points): .
- Subtask 4 (30 points): For all testdata, a solution is guaranteed to exist.
- Subtask 5 (48 points): No special restrictions.
For of the testdata, , , , .
Translated by ChatGPT 5