1.21英文题面翻译

描述

Acm, a treasure-explorer, is exploring again. This time he is in a special maze, in which there are some doors (at most 5 doors, represented by 'A', 'B', 'C', 'D', 'E' respectively). In order to find the treasure, Acm may need to open doors. However, to open a door he needs to find all the door's keys (at least one) in the maze first. For example, if there are 3 keys of Door A, to open the door he should find all the 3 keys first (that's three 'a's which denote the keys of 'A' in the maze). Now make a program to tell Acm whether he can find the treasure or not. Notice that Acm can only go up, down, left and right in the maze.

输入

The input consists of multiple test cases. The first line of each test case contains two integers M and N (1 < N, M < 20), which denote the size of the maze. The next M lines give the maze layout, with each line containing N characters. A character is one of the following: 'X' (a block of wall, which the explorer cannot enter), '.' (an empty block), 'S' (the start point of Acm), 'G' (the position of treasure), 'A', 'B', 'C', 'D', 'E' (the doors), 'a', 'b', 'c', 'd', 'e' (the keys of the doors). The input is terminated with two 0's. This test case should not be processed.

输出

For each test case, in one line output "YES" if Acm can find the treasure, or "NO" otherwise.

OpenJudge - 1159:Maze

翻译

描述

Acm,一个寻宝者,又开始了探索。这次他在一个有一些门的迷宫中(最多五扇门,用A,B,C,D,E代表)。为了找到财宝,Acm可能需要打开这些门。然而,他需要先在迷宫中找到这些门的钥匙(至少一把)才能打开它们。例如,如果打开门A需要三把钥匙,那么他需要把三把钥匙全部找到才能打开A门(迷宫中有三个“a”代表这三把钥匙)。现在写一个程序告诉Acm他是否能找到财宝。注意Acm在迷宫中只能向前后左右走动。

输入

输入由多个测试样例组成。每个样例的第一行包含两个整数M和N(1<N,M<20),代表迷宫的大小。接下来的M行给出了迷宫的排布,每一行包含N个字符。字符可能是一下内容:“X”(代表一堵墙,探索者不能够进入);“.”(空的通道);“S”(Acm开始的位置);“G”,(财宝的位置);“A,B,C,D,E”(门);“a,b,c,d,e”(门的钥匙)。输入以两个“0”表示结束。

输出

对于每个测试数据,输出“YES”如果Acm能获得财宝,否则输出“NO”。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值