| antontrygubO_o UOI problems |
|---|
| Finished |
There are $$$k$$$ arrays of integers $$$a_1, a_2, \ldots, a_k$$$, where the array with index $$$i$$$ contains $$$l_i$$$ elements. Let $$$n = l_1 + l_2 + \ldots + l_k$$$.
You need to find $$$k$$$ integers $$$d_1, d_2, \ldots, d_k$$$ such that the numbers $$$(a_{i,j} + d_i)$$$ are pairwise distinct and satisfy $$$1 \leq a_{i,j} + d_i \leq n$$$.
The first line contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le n \le 10^4$$$, $$$1 \le k \le 5$$$) – the total number of elements in the arrays and the number of arrays, respectively.
The next $$$k$$$ lines contain the arrays. The $$$i$$$-th line contains an integer $$$l_i$$$ ($$$1\le l_i\le n$$$) and $$$l_i$$$ integers $$$a_{i,1},a_{i,2},\ldots,a_{i,l_i}$$$ ($$$1 \le a_{i,j} \le n$$$) – the length and elements of the $$$i$$$-th array, respectively.
It is guaranteed that $$$n = l_1 + l_2 + \ldots + l_k$$$.
If the required values of $$$d$$$ do not exist, output a single line "No".
Otherwise, output "Yes" on the first line.
On the second line, output $$$k$$$ integers $$$d_1,d_2,\ldots,d_k$$$ – the values that need to be added to the elements of the arrays to form a total of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$.
If there are multiple correct answers, any one of them may be output.
5 5 1 1 1 2 1 3 1 4 1 5
Yes 0 0 0 0 0
6 4 2 2 3 1 6 1 4 2 1 5
Yes 1 -5 1 1
7 2 4 1 4 5 6 3 1 2 6
Yes 0 1
4 2 2 2 3 2 2 4
No
In the first example, $$$d = [0,0,0,0,0]$$$ satisfies the condition, since after adding the corresponding values, the arrays $$$[1]$$$, $$$[2]$$$, $$$[3]$$$, $$$[4]$$$, $$$[5]$$$ are formed.
In the second example, $$$d = [1,-5,1,1]$$$ satisfies the condition, since after adding the corresponding values, the arrays $$$[3,4]$$$, $$$[1]$$$, $$$[5]$$$, $$$[2,6]$$$ are formed.
In the third example, $$$d = [0,1]$$$ satisfies the condition, since after adding the corresponding values, the arrays $$$[1,4,5,6]$$$ and $$$[2,3,7]$$$ are formed.
| Name |
|---|


