PKU 3702 Chessman

Description

There's an n × 1 chessboard filled with some chessman, where n is infinity. For each chessman, you can make any move of the following:

1.Jump to the 4th grid on the right or left, if that grid is empty. For example:
...*........
=>
.......*....

...****.....
=>
....****....

....*.**....
=>
...**.*.....

2. Jump to the 3rd grid on the right, if that grid is empty, as well as the second and the first grid on the right has and has not a chessman respectively. Then, after this the junp is taken, the first grid the chessman jumped over will have a chessman, and the second grid the chessman jumped over will be empty. For example:

...*.*.....
=>
....*.*....

3.Jump to the 2nd grid on the right, if that grid is empty and the grid the chessman is about to jump over has a chessman. Then, the grid the chessman jumped over will be empty. For example:

...**.....
=>
.....*....

Given the first 30 girds on the left (has or has not chessman) of two chessboards, the rest grids being all empty, decide whether the first chessboard can be changed to the second chessboard with those three kinds of moves listed above?

Input

The first line of the input is the number of test cases. For each case there are two lines. Each line contains 30 characters. '.' represents empty grid. '*' represents a chessman. There is a blank line before each test case.

Output

For each test case output the answer on a line: "YES" or "NO".  

Sample Input

6

........................*.....
.........................*....

......*.......*...............
.........................*....

******************************
................**............

*...*..**.....................
...........................***

*******.****.**************.**
..**...*..*..*...**.*...**.*..

*******.****.**************.**
..**...**.*..*...**.*...**.*..

Sample Output

NO
NO
YES
NO
YES
NO

直接说思路吧。将数据分成四组,安装%4划分,只要计数就可以了。之所以这样,因为每组之间可以只有移动,根据规则1. 然后根据规则2,3,可以修改4组之间的数量关系,这就是dfs的内容。关键在于规则1的只有移动,使得组内的位置关系没有意义,因此只要从计数考虑就可以了。



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值