#P9764. [ROIR 2021] 绳子 (Day 1)

[ROIR 2021] 绳子 (Day 1)

Background

Translated from ROIR 2021 Day 1 T4 Антенна

Problem Description

There are nn ropes. The ii-th rope has length sis_i cm and has mim_i nodes. The jj-th node is located at pi,jp_{i,j} 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 qq. Clearly, qq is a permutation of 1n1 \sim n, and it must satisfy the following requirement: after connecting the right endpoint of rope qiq_i to the left endpoint of rope qi+1q_{i+1} (1i<n)(1\le i<n), 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 nn.

The next 2×n2\times n lines are:

  • Line 2×i(1in)2\times i(1\le i\le n) contains two integers mim_i and sis_i.
  • Line 2×i+1(1in)2\times i+1(1\le i\le n) contains mim_i integers pi,jp_{i,j}.

Output Format

If a plan can be constructed, output Yes, and then output one more line containing nn integers qiq_i.

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]:

p9lIOqe.png

[Constraints]:

For all subtasks, 1n1051\le n\le 10^5, 1mi1051\le m_i\le 10^5, 0si1090\le s_i\le 10^9, 0pi,1<pi,2<<pi,misi0\le p_{i,1}<p_{i,2}<\cdots<p_{i,m_i}\le s_i, mi105\sum m_i\le 10^5.

Subtask ID Special Constraints Score
11 n8n\le 8, mi=1m_i=1, si100s_i\le 100 88
22 n8n\le 8, si100s_i\le 100
33 n103n\le 10^3 2121
44 mi>n\sum m_i>n
55 si100s_i\le 100
66 No special constraints

Translated by ChatGPT 5