시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 (추가 시간 없음) | 512 MB | 4 | 3 | 2 | 66.667% |
You are given an integer $n$ and a number of non-empty sets of elements from $0$ to $n-1$.
Construct a permutation $p$ of length $n$, such that for every given set $S$ the following holds: $$\max_{s \in S} p_s - \min_{s \in S} p_s = |S| - 1\text{.}$$
The solution is guaranteed to exist. If there are multiple solutions output any.
The first line contains two integers $n$ and $m$ ($3 \leq n \leq 100, 1 \leq m \leq 100$), length of the permutation and the number of sets.
$m$ lines follow. $i$-th of them contains an integer $k_i$ ($2 \leq k_i < n$) followed by $k_i$ integers $a_{i,j}$ ($0 \leq a_{i,j} < n, a_{i,j}<a_{i,j+1}$), size of the $i$-th set and its elements themselves.
It is guaranteed that the given sets are pairwise distinct and the answer exists.
Print $n$ integers. $i$-th of them should be equal to $p_i$.
3 1 2 0 1
0 1 2
8 5 3 4 5 7 3 2 3 6 3 2 5 7 2 4 5 2 1 6
7 6 3 4 0 1 5 2