P29146 [洛谷] [ROIR 2021 Day 1] Ropes
入门
题目描述

Problem Description

There are $n$ ropes, with the $i$-th rope being $s_i$ cm long and having $m_i$ nodes. The $j$-th node is located $p_{i,j}$ cm from the left end of the rope.

Construct a scheme to connect the ropes from left to right. Let the sequence of ropes be $q$, which is obviously a permutation of $1$ to $n$, and satisfies the following requirement: after connecting the right end of the $q_i$-th rope to the left end of the $q_{i+1}$-th rope $(1 \le i < n)$, the distances between adjacent nodes are equal.

It is clear that there may be no solution. In this case, output No.

Input Format

The first line contains an integer $n$.

The next $2 \times n$ lines are as follows:

  • The $2 \times i$-th line $(1 \le i \le n)$ contains two integers $m_i$ and $s_i$.
  • The $2 \times i + 1$-th line $(1 \le i \le n)$ contains $m_i$ integers $p_{i,j}$.

Output Format

If a solution can be constructed, output Yes, followed by a line containing $n$ integers $q_i$.

If there is no solution, output No.

Sample Input and Output

Input Sample #1

3
1 7
3
1 8
6
2 8
1 6

Output Sample #1

Yes
2 1 3

Input Sample #2

1
1 7
5

Output Sample #2

Yes
1

Input Sample #3

1
3 10
2 5 9

Output Sample #3

No

Input Sample #4

3
1 5
3
1 3
3
1 6
3

Output Sample #4

No

Input Sample #5

4
1 5
0
1 0
0
1 3
3
1 0
0

Output Sample #5

Yes
3 2 1 4

Notes

Sample Explanation 1:

Explanation Image
Explanation Image

Data Range:

For all subtasks, $1 \le n \le 10^5$, $1 \le m_i \le 10^5$, $0 \le s_i \le 10^9$, $0 \le p_{i,1} < p_{i,2} < \cdots < p_{i,m_i} \le s_i$, $\sum m_i \le 10^5$.

Subtask Number Special Constraints Score
1 $n \le 8$, $m_i = 1$, $s_i \le 100$ 8
2 $n \le 8$, $s_i \le 100$ 8
3 $n \le 10^3$ 21
4 $\sum m_i > n$ 21
5 $s_i \le 100$ 21
6 None 21
输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 1 7 3 1 8 6 2 8 1 6
样例输出
Yes 2 1 3