CF585B.Phillip and Trains
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.

移动应用商店推出了一款新游戏,名为“地铁滚轮”(Subway Roller)。
游戏主角菲利普(Philip)位于隧道的一端,目标是抵达另一端。该隧道是一个由三行 n 列组成的矩形区域。游戏开始时,主角位于最左侧一列的某个格子中。若干列火车正朝主角驶来。每列火车由某一行中两个或更多相邻的格子组成。
所有火车均以每秒向左移动两格的速度行进;而主角则以每秒向右移动一格的速度奔跑。为简化实现,游戏采用回合制:主角与火车交替行动。首先,主角向右移动一格,然后可选择向上、向下移动一格,或保持不动;接着,所有火车同时向左移动一格(此过程重复两次)。因此,在一个完整回合中,主角必定向右移动一格,并可额外选择向上、向下或静止。若在任意时刻,主角与火车处于同一格子,则游戏失败。若火车抵达最左侧一列,它将继续按原方式向左移动并驶出隧道。
你的任务是判断:是否存在一种主角的移动序列,使其能够成功抵达最右侧一列?

输入格式
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.
每组测试包含一至十组输入数据。测试的第一行包含一个整数 t(预测试和正式测试中满足 1≤t≤10,而针对 Hack 的测试中 t=1;具体细节请参见“注意事项”部分),表示输入数据组数。
随后是 t 组输入数据的描述。
每组数据描述的第一行包含两个整数 n、k(2≤n≤100,1≤k≤26),分别表示游戏场地的列数与列车数量。接下来三行,每行包含 n 个字符,表示游戏场地的一行。Philip 的初始位置标记为 's',且他位于最左侧一列。每列火车由一串相同的英文字母(大写)表示,且全部位于同一行中;不同列车用不同的字母表示。字符 '.' 表示空单元格,即既不包含 Philip 也不包含任何列车的单元格。
输出格式
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.
对于每组输入数据,如果可以赢得游戏,则在一行中输出单词 YES;否则输出单词 NO。
输入输出样例
输入#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.
在第一个样例的输入的第一组数据中,菲利普必须首先向前移动,然后向下移动至场地的第三行,接着仅向前移动,再向前移动并向上爬升至第二行,再次向前移动并向上爬升至第一行。此后,他的路径不再被任何火车阻挡,因此他可以一直直线前进到达隧道尽头。
注意:本题的测试用例限制为仅包含一组测试集。
输入解题思路,AI测评打分。不知道怎么写?