P7123 [NEERC 2016] Indiana Jones and the Uniform Cave

题目背景

这是一道 IO 交互题。

题目描述

现在在一个洞穴里寻宝。这个洞穴有 $n$ 个房间。房间是不可区分的。每个房间都引出 $m$ 个单向道路,终点可以是自己也可以是其它房间。这些单向道路的入口均匀地分布在房间的墙壁上,且每条单向道路也是不可区分的。保证整个有向图是强连通的。你一开始在某一个房间,如果遍历了所有的边,就能找到宝藏。 每个房间有一个石子,这也是你区分房间和道路的唯一工具。一开始石子是在这个房间的某一个通道的入口前,并且是放在中央的。你每到一个房间,可以选择将石子移动到某个通道前,把它放在通道左边或者右边(不能是中间),然后再从某个通道走出去。你不可以把石子带出房间。你并没有携带过多的食物,所以如果你走了超过 $20000$ 条边,你就会因为食物耗尽而饿死。你要在规定步数之内找到宝藏。

输入格式

输出格式

说明/提示

Dr. Jones enters the example cave and sees that the stone in the first chamber is in the center. He marks the chamber by placing the stone to the left of some passage and takes it. He sees the chamber where the stone is to the left of the passage, so he is in the first chamber again. He moves the stone clockwise and takes the passage marked by it. This passage leads to the second chamber. He marks it by placing the stone to the right of some passage and takes another one. He is in the first chamber again, so he returns to the second chamber and takes the remaining passage. This passage leads to the treasure.