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

24780번 - Kitten on a Tree 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB87706281.579%

문제

Ouch! A kitten got stuck on a tree. Fortunately, the tree's branches are numbered. Given a description of a tree and the position of the kitten, can you write a program to help the kitten down?

입력

The input is a description of a single tree. The first line contains an integer $K,ドル denoting the branch on which the kitten got stuck. The next lines each contain two or more integers $a, b_1, b_2, \ldots$. Each such line denotes a branching: the kitten can reach $a$ from $b_1, b_2, \ldots$ on its way down. Thus, $a$ will be closer to the root than any of the $b_i$. The description ends with a line containing -1. Each branch $b_i$ will appear on exactly one line. All branch numbers are in the range 1ドル..100,ドル though not necessarily contiguous. You are guaranteed that there is a path from every listed branch to the root. The kitten will sit on a branch that has a number that is different than the root.

The illustration above corresponds to the sample input.

출력

Output the path to the ground, starting with the branch on which the kitten sits.

제한

예제 입력 1

14
25 24
4 3 1 2
13 9 4 11
10 20 8 7
32 10 21
23 13 19 32 22
19 12 5 14 17 30
14 6 15 16
30 18 31 29
24 23 26
26 27 28
-1

예제 출력 1

14 19 23 24 25

힌트

출처

School > Virginia Tech High School Programming Contest > 2015 Virginia Tech High School Programming Contest F번

  • 문제를 만든 사람: Godmar Back
(追記) (追記ここまで)

출처

대학교 대회

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

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