Hide

Problem K
Urban Explorer

/problems/urbanexplorer/file/statement/en/img-0001.jpeg
Explorer getting chased by guard

You are an urban explorer who has run into a security guard on one of your late night excursions, where you parachuted into a maze of rooms. Luckily you have a map of all of the rooms, how they are connected, and the location of the exit. Additionally, you have one other thing that has kept you safe on your adventures, you have super hearing good enough to pinpoint the exact room that the security guard is in as he chases you. Unfortunately, the security guard has CCTV footage and knows the exact layout of all rooms and where you are as well. You luckily saw the guard first so you are one move ahead of the guard.

Assuming both you and the security guard move optimally and at the same speed, print out whether the guard will catch you, whether you will escape, or if there will be a stalemate. A stalemate occurs when the guard cannot catch you, but you also cannot reach the exit room without getting caught.

Thus, you and the security guard move in turns and during that turn whoever’s turn it is must move to one of the rooms adjacent to their current room. For example, if the security guard is in room $1$ that is connected only to room $2$ and it is their turn, they must move to room $2$. Additionally, the security guard is not allowed to occupy the room with the exit.

This game may end in one of two ways:

  1. If the security guard ever occupies the same room as the urban explorer, the security guard wins and catches the explorer.

  2. If the urban explorer ever reaches the exit room, the urban explorer wins.

If under optimal movement by both you and guard neither situation occurs, you are stuck in a stalemate.

Input

On the first line of input, you are given an integer $m$ ($3 \leq m \leq 50$) representing the number of rooms. This line is followed by $m$ lines with each line representing a room, where the rooms are numbered from $0$ to $m-1$. On the $i^{\text {th}}$ line there is an integer $n$ ($0 \leq n \leq m$) denoting how many rooms are connected to room $i$. This is followed by $n$ integers $i_ k$ ($0 \leq i_ k < m$ and $k \in \{ 1 \ldots n\} $) on the same line representing the numbers of the rooms to which room $i$ is connected. You may assume that there are no one-way passages between rooms, that is, if there is a passage from room $i$ to room $j$ then there is also a passage from room $j$ to room $i$. The exit is always room $0$. The urban explorer always starts at room $1$, and the guard starts at room $2$.

Output

Print out “Caught” if the guard catches you, “Escaped” if you can reach the exit before the guard, and “Stuck” if it is a stalemate.

Sample Input 1 Sample Output 1
4
2 1 3
1 0
1 3
2 0 2
Escaped
Sample Input 2 Sample Output 2
6
2 2 5
1 3
3 0 4 5
3 1 4 5
2 2 3
3 0 2 3
Stuck
Sample Input 3 Sample Output 3
4
1 2
2 2 3
2 0 1
1 1
Caught

Please log in to submit a solution to this problem

Log in