303006: CF585B. Phillip and Trains

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Phillip and Trains

题意翻译

# 题目描述 应用商店里出现了一种手机游戏,名字叫“地铁跑酷”,这个游戏规则如下: 隧道里有三条轨道,长都是n格。英雄游戏人物会在轨道最左边任意一条轨道出现,每条轨道上还有一些辆火车,向左冲向英雄,然后从左侧消失。(每列火车至少长两个格) jyf玩了一会,觉得挺好玩的,要是能快速判断出能不能将游戏人物从左走到右就最好了。于是他将这个游戏问题更具体化描述如下: ![](https://cdn.luogu.org/upload/vjudge_pic/CF585B/309f950d64c5a7d55f4952aae670b86363abc76b.png) 这个游戏可以看成回合制,首先游戏人物向右一步(如果此时撞到火车就死了)。接着,可以选择向上或者向下一步或者停在原地(不能碰到火车)。然后轮到所有火车同时向左开两格。在任何时候火车撞到到游戏人物,游戏人物也死了。火车会一直向左开,直到完全消失。 赢的条件很简单,游戏人物能躲避所有火车并到达最右边,就算赢。 问题描述完毕,jyf希望聪明的你快速的解决这个问题。 # 输入输出格式 ## 输入 首先输入T (1<=t<=10),表示有T组测试数据 对于每个测试数据,首先输入n, k,分别表示火车轨道长度和火车数量 (2<=n<=100, 1<=k<=26) 接下来3行每行输入n个字符,要么是 '.' 表示轨道上没有火车,要么是大写的英文字母表示某种火车(连续同样的英文字母表示一列火车) 最左侧有一行的第一个字符为 's' ,表示游戏人物初始位置。 ## 输出 对于每组测试数据,如果能赢输出”YES”,否则输出”NO”

题目描述

The mobile application store has a new game called "Subway Roller". The protagonist of the game Philip is located in one end of the tunnel and wants to get out of the other one. The tunnel is a rectangular field consisting of three rows and $ n $ columns. At the beginning of the game the hero is in some cell of the leftmost column. Some number of trains rides towards the hero. Each train consists of two or more neighbouring cells in some row of the field. All trains are moving from right to left at a speed of two cells per second, and the hero runs from left to right at the speed of one cell per second. For simplicity, the game is implemented so that the hero and the trains move in turns. First, the hero moves one cell to the right, then one square up or down, or stays idle. Then all the trains move twice simultaneously one cell to the left. Thus, in one move, Philip definitely makes a move to the right and can move up or down. If at any point, Philip is in the same cell with a train, he loses. If the train reaches the left column, it continues to move as before, leaving the tunnel. Your task is to answer the question whether there is a sequence of movements of Philip, such that he would be able to get to the rightmost column. ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF585B/309f950d64c5a7d55f4952aae670b86363abc76b.png)

输入输出格式

输入格式


Each test contains from one to ten sets of the input data. The first line of the test contains a single integer $ t $ ( $ 1<=t<=10 $ for pretests and tests or $ t=1 $ for hacks; see the Notes section for details) — the number of sets. Then follows the description of $ t $ sets of the input data. The first line of the description of each set contains two integers $ n,k $ ( $ 2<=n<=100,1<=k<=26 $ ) — the number of columns on the field and the number of trains. Each of the following three lines contains the sequence of $ n $ character, representing the row of the field where the game is on. Philip's initial position is marked as 's', he is in the leftmost column. Each of the $ k $ trains is marked by some sequence of identical uppercase letters of the English alphabet, located in one line. Distinct trains are represented by distinct letters. Character '.' represents an empty cell, that is, the cell that doesn't contain either Philip or the trains.

输出格式


For each set of the input data print on a single line word YES, if it is possible to win the game and word NO otherwise.

输入输出样例

输入样例 #1

2
16 4
...AAAAA........
s.BBB......CCCCC
........DDDDD...
16 4
...AAAAA........
s.BBB....CCCCC..
.......DDDDD....

输出样例 #1

YES
NO

输入样例 #2

2
10 4
s.ZZ......
.....AAABB
.YYYYYY...
10 4
s.ZZ......
....AAAABB
.YYYYYY...

输出样例 #2

YES
NO

说明

In the first set of the input of the first sample Philip must first go forward and go down to the third row of the field, then go only forward, then go forward and climb to the second row, go forward again and go up to the first row. After that way no train blocks Philip's path, so he can go straight to the end of the tunnel. Note that in this problem the challenges are restricted to tests that contain only one testset.

Input

题意翻译

# 题目描述 应用商店里出现了一种手机游戏,名字叫“地铁跑酷”,这个游戏规则如下: 隧道里有三条轨道,长都是n格。英雄游戏人物会在轨道最左边任意一条轨道出现,每条轨道上还有一些辆火车,向左冲向英雄,然后从左侧消失。(每列火车至少长两个格) jyf玩了一会,觉得挺好玩的,要是能快速判断出能不能将游戏人物从左走到右就最好了。于是他将这个游戏问题更具体化描述如下: ![](https://cdn.luogu.org/upload/vjudge_pic/CF585B/309f950d64c5a7d55f4952aae670b86363abc76b.png) 这个游戏可以看成回合制,首先游戏人物向右一步(如果此时撞到火车就死了)。接着,可以选择向上或者向下一步或者停在原地(不能碰到火车)。然后轮到所有火车同时向左开两格。在任何时候火车撞到到游戏人物,游戏人物也死了。火车会一直向左开,直到完全消失。 赢的条件很简单,游戏人物能躲避所有火车并到达最右边,就算赢。 问题描述完毕,jyf希望聪明的你快速的解决这个问题。 # 输入输出格式 ## 输入 首先输入T (1<=t<=10),表示有T组测试数据 对于每个测试数据,首先输入n, k,分别表示火车轨道长度和火车数量 (2<=n<=100, 1<=k<=26) 接下来3行每行输入n个字符,要么是 '.' 表示轨道上没有火车,要么是大写的英文字母表示某种火车(连续同样的英文字母表示一列火车) 最左侧有一行的第一个字符为 's' ,表示游戏人物初始位置。 ## 输出 对于每组测试数据,如果能赢输出”YES”,否则输出”NO”

加入题单

上一题 下一题 算法标签: