-->
当前位置:首页 > 题库

PROGRAMMING:Go deep into the tiger's Den

Luz5年前 (2021-05-10)题库467
The famous ace spy 007 needs to perform a mission to obtain the enemy's confidential information. The known information is hidden in an underground labyrinth. The labyrinth has only one entrance. There are many paths in it, and each path leads to a door. Behind each door, there is a room, or there are many roads, and each road leads to a door... He has a form in his hand, which is the information collected by other spies for him. They have written down the number of each door, and the number of the door to which each passage behind this door reaches. 007 found that there were no two roads leading to the same door.
Inside sources told him that the information was hidden in the deepest part of the maze. But this maze is too big, he needs your help - please program to help him find the door farthest from the entrance.
###Input format:
Input first gives a positive integer $$n $$($< 10 ^ 5 $$) in one line, which is the number of doors. Finally, line $$n $, line $$I $($$1 / Le I / Le n $) describes the door that can be accessed behind the door numbered $$I $) in the following format:
```
K D[1] D[2] ... D[K]
```
Where 'k' is the number of passages followed by the number of each door.
###Output format:
Output the number of the door farthest from the entrance in one line. The title guarantees that the result is unique.
###Input example:
```in
thirteen
3 2 3 4
2 5 6
1 7
1 8
1 9
0
2 11 10
1 13
0
0
1 12
0
0
```
###Output example:
```out
twelve
```







answer:If there is no answer, please comment