loj#P3476. 「ROIR 2021 Day 1」绳子
「ROIR 2021 Day 1」绳子
Description
Translated from Chinese version of ROIR 2021 Day1 T4 Антенна on this website.
There are ropes, among which the -th rope is centimeter long. Besides, nodes are on that rope, and the -th node is centimeter away from the leftmost side of the rope.
Your task is to find a solution to connect ropes from left to right satisfying that all distances between adjacent nodes equals after connecting -th and -th ropes, whereas represents the solution and would obviously be a permutation of .
Output No
if such solution does not exist.
Input Format
The first line will be an integer .
In the following lines:
- The -th line would be two integers, and
- The -th line would be integers, respectively
Note that the value of above satisfies .
Output Format
If the solution could be found, output Yes
in the first line and integers in the following line.
Otherwise, 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
Constraints
It is guaranteed that for all subtasks, there are , , , , .
Subtask # | Additional Constraints | Score |
---|---|---|
,, | ||
, | ||
No additional constraints |