Logo
(追記) (追記ここまで)

18988번 - Mall 스페셜 저지다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 256 MB68463772.549%

문제

Byton has been sent by his parents to a nearby shopping mall to buy $m$ products from the list, numbered 1ドル$ through $m$. As he loves shopping, he plans to visit every shop in the mall, each of them exactly once. Byton is going to visit the shops in some order and in some of them, he will buy some products from the list that he has not bought yet.

As you can guess, some products may be available in multiple different shops. Unfortunately, Byton is a bit paranoid -- he fears random security checks very much. Therefore, he would like to avoid an awkward situation in which he enters a shop that sells a product that he has already purchased somewhere else.

Can you find a strategy of visiting all the shops and buying products, which will allow Byton to avoid awkward situations with security guards?

입력

The first line of the input contains two integers $n, m$ (1ドル \le n, m \le 1000$) -- the number of shops in the mall and the number of products Byton needs to buy, respectively. The next $n$ lines describe shops in the mall; the $i$-th of them describes the $i$-th shop. Each description begins with a number $k_i$ (1ドル\leq k_i\leq m$) denoting the number of products of Byton's interest available in the $i$-th shop. Then, $k_i$ integers, each between 1ドル$ and $m,ドル follow in ascending order. Each of them denotes a product from Byton's list.

출력

If there does not exists a correct strategy of shopping, you should output a single word NO. Otherwise, the first line of the input should contain the word YES. The second line of the output should contain $n$ distinct integers ranging from 1ドル$ to $n$ -- the order of shops visited by Byton. The last, third line should contain $m$ integers ranging from 1ドル$ to $n$; the $i$-th of them indicates the shop in which Byton should buy the product $i$. If there are multiple solutions, output any of them.

제한

예제 입력 1

4 4
1 2
2 2 4
2 1 3
1 1

예제 출력 1

YES
1 2 3 4
4 2 3 2

힌트

First, Byton should go to shop 1ドル,ドル not buying anything. Then, he should go to shop 2ドル$ and buy the products 2ドル$ and 4ドル$. Next, he can buy product 3ドル$ in shop 3ドル$ and finally buy product 1ドル$ in shop 4ドル$.

출처

Camp > Petrozavodsk Programming Camp > Summer 2018 > Day 5: Warsaw U Contest, XVIII Open Cup named after E.V. Pankratiev Onsite A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /