-->
当前位置:首页 > 题库 > 正文内容

PROGRAMMING:Zhe zhe plays games

Luz3年前 (2021-05-10)题库245
Zhe Zhe is a hard core gamer. Recently, a new game named "Dano Dano" has just come into the market. Zhe zhe naturally wants to quickly attack the game and protect everything of hard core game players!
In order to simplify the model, we might as well assume that the game has $$n $$plot points. Through different operations or choices in the game, we can go from one plot point to another. In addition, the game also sets up some * * archive * * to save the player's game progress in a file at a plot point. After reading the archive, you can go back to the plot point, operate or select again, and reach different plot points.
In order to track the progress of Zhezhe's strategy, you plan to write a program to complete the work. Suppose you already know all the plot and flow of the game, as well as Zhezhe's game operation, please output Zhezhe's game progress.
###Input format:
The first line of input is two positive integers $$n $$and $$M $$($$1 / Le n, M / Le 10 ^ 5 $$), indicating that there are a total of $$n $$plot points and that zhe zhe has $$M $$game operations.
The next $$n $$line corresponds to the development setting of a plot point. The first number in line $$I $$is $$K_ I $$, which means that the plot point $$I $$can go to the following $$k through some operation or selection_ I $$plot points; Next comes $$K_ I $$number, the $$k $$number means to do the $$k $$operation or select the plot point number to go to.
Finally, there are $$M $$lines. The first number of each line is 0, 1 or 2, respectively
*0 means that zhe zhe has made an operation or choice, followed by a number $$J $, which means that zhe zhe has made the $$J $$choice at the current plot point. We guarantee that zhe Zhe's choice will always be legal.
*1 means that Zhezhe has made an archive, followed by a number $$J $, which means that the archive is placed in the $$J $$.
*2 indicates that zhe zhe has read the archive once, followed by a number $$J $$, indicating that he has read the archive placed in the $$J $$.
Convention: all operations or selections and plot point numbers start from the 1st. There are no more than 100 files on file, and the number starts from 1. The game starts from plot 1 by default. The total number of options (i.e. $$sum K)_ I $$) no more than $$10 ^ 6 $$.
###Output format:
For each 1 (i.e. Archive) operation, output the archived plot point number in one line.
The last line outputs the plot point number of zhe Zhe's last arrival.
###Input example:
```in
10 11
3 2 3 4
1 6
3 4 7 5
1 3
1 9
2 3 5
3 1 8 5
1 9
2 8 10
0
1 1
0 3
0 1
1 2
0 2
0 2
2 2
0 3
0 1
1 1
0 2
```
###Output example:
```out
one
three
nine
ten
```
###Example explanation:
The sequence of plot points in the example is given briefly
1 -> 4 -> 3 -> 7 -> 8 -> 3 -> 5 -> 9 -> 10。
Gear 1 starts to store plot point 1; Gear 2 stores plot point 3; Gear 1 later saved plot 9.







answer:If there is no answer, please comment

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。