Maze Treasure Hunt (i.)time limit:ms | Memory limit:65535 KB Difficulty:4
- Describe
-
A treasure-seeker named ACM found a treasure map, it found a maze according to the treasure map, this is a very special maze, there are N numbered in the maze of the door (n<=5), they were numbered a,b,c,d, E. In order to find the treasure, ACM must open the door, but before opening the door must find all the keys needed to open the door (at least one key for each door), for example: Now that a door has three keys, ACM must find all three keys to open a door. Now ask you to write a program to tell ACM that he can get the treasure well.
-
- Input
-
- The input may have multiple sets of test data (no more than 10 groups). The first line of each set of test data contains two integers m,n (1<n,m<20), representing the rows and columns of the maze, respectively. The next m has n characters per line, describing the layout of the maze. Each of these characters has the following meanings:. Indicates the possible path S: The starting point of ACM represents the location of the treasure X means that there is a wall, ACM cannot enter or pass through. A,b,c,d,e says this is the door, a,b,c,d,e the key on the door that corresponds to the capital letter. Note that ACM can only move up or down in the maze in four directions.
Finally, enter 0 0 to indicate the end of the input.
-
- Output
-
- each line outputs a yes to indicate that ACM can find the treasure, and the output no means that ACM cannot find the treasure.
-
- Sample input
-
-
4 4 s.x. a.x ... XG .... 3 4 s.xa. AXB B.ag 0 0
-
- Sample output
-
-
YES NO
Nyoj 82 Maze Hunt (i)