#P9764. [ROIR 2021] 绳子 (Day 1)
[ROIR 2021] 绳子 (Day 1)
Background
Translated from ROIR 2021 Day 1 T4 Антенна。
Problem Description
There are ropes. The -th rope has length cm and has nodes. The -th node is located at cm from the left endpoint of the rope.
Try to construct a plan to connect the ropes from left to right. Let the order of ropes in this plan be . Clearly, is a permutation of , and it must satisfy the following requirement: after connecting the right endpoint of rope to the left endpoint of rope , the distances between adjacent nodes are equal.
Obviously, there may be no valid plan. In this case, output No.
Input Format
The first line contains an integer .
The next lines are:
- Line contains two integers and .
- Line contains integers .
Output Format
If a plan can be constructed, output Yes, and then output one more line containing integers .
If there is no solution, output No.
3
1 7
3
1 8
6
2 8
1 6
Yes
2 1 3
1
1 7
5
Yes
1
1
3 10
2 5 9
No
3
1 5
3
1 3
3
1 6
3
No
4
1 5
0
1 0
0
1 3
3
1 0
0
Yes
3 2 4 1
Hint
[Sample Explanation 1]:

[Constraints]:
For all subtasks, , , , , .
| Subtask ID | Special Constraints | Score |
|---|---|---|
| , , | ||
| , | ||
| No special constraints |
Translated by ChatGPT 5