Yiner的ACM

成长的痕迹
<2011年3月>
272812345
6789101112
13141516171819
20212223242526
272829303112
3456789

统计

  • 随笔 - 29
  • 文章 - 0
  • 评论 - 2
  • 引用 - 0

常用链接

留言簿(1)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜

基础深搜题

  An escape

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 227    Accepted Submission(s): 56

Problem Description

You are now in a maze. You mark all the blocks you've visited by '@',
 so when you see a wall '#' or a visited block '@' in front of you, you
 will make a right turn. Otherwise, that means you don't have a wall or a
 visited block in front, you'll go forward. When you reach the door 'D', congratulations!


####
#Y@#
##D#
####

Look at the maze above, you are now in 'Y', facing left, and seeing a wall in
 front of you. You turn right, a wall again; turn right again, visited block;
 turn right once again, still a wall. After three continuous turnings, you realize 
the rest time of your life will be making turnings.

 

Input

The first line is T(T<=20), then T cases follow.
Each case has two numbers n and m(4<=n,m <= 20), the boundary of the maze will 
always be '#', in the maze, there will 
be exactly one 'Y', one 'D'. Normal blocks are marked with '.'.


At first you are facing left.

 

Output

"YES" if you can go out of the maze(reach 'D'). "NO" otherwise.

 

Sample Input

2

4 4

####

#.Y#

##D#

####

4 4

####

#.Y#

#D##

####

 

Sample Output

NO

YES

 

Author

MadFroG
自己写的超长代码如下:

深搜的代码

posted on 2011-03-13 11:30 Yiner 阅读(378) 评论(0)  编辑 收藏 引用 所属分类: DFS


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理