Nyoj 82 Maze Treasure Hunt (i)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.