301910: CF362A. Two Semiknights Meet

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

Description

Two Semiknights Meet

题意翻译

### 题目描述 一个名叫彼佳的男孩非常喜欢国际象棋。他甚至发明出了一种棋——“半骑士”。半骑士可以在这四个方向中的任何一个方向移动:向右前方2个方格,向左前方2个方格,向左后方2个方格,向右后方2个方格(译注:类似中国象棋中的象),当然,半骑士不能走出棋盘。 彼佳在标准棋盘上放了两个半骑士并同时移动它们。棋盘相当大,所以经过一些移动后半骑士可能相遇,也就是说,它们最终可能会在同一个方格中,这称为一次会面。会面结束后,半骑士们可以继续前进,因此它们有可能再次见面。彼佳认为一些方格不好。也就是说,它们不适合会面。 半骑士们可以穿过这些方格,但他们在这些方格中的会面不计算在内。 彼佳准备了多个国际象棋棋盘。帮助彼佳找出半骑士是否可以在每个棋盘的某个好方格上相遇。 请结合测试数据分析。 ## 输入输出格式 ### 输入格式: 第一行包含数字t(1 <= t <= 50)——棋盘数量。 每个棋盘由一个字符矩阵描述,由8行和8列组成。矩阵由字符“.”,“#”与“K”组成,表示空的方格(好方格),坏方格和半骑士的位置。 保证矩阵恰好包含2个半骑士。半骑士们一开始所在的两个方格(输入“K”的地方)被看作好方格。每个矩阵之间用空行(回车)分隔。 ### 输出格式: 对于每个矩阵,只输出一行: 若半骑士们可以在某个好方格上会面,输出"YES"(不含引号),反之则输出"NO"。 ## 说明 我们将假设矩阵的行和列从上到下和从左到右编号为1到8。在第一块棋盘中,半骑士们可以在方格(2,7)中相遇。在方格(4,1)的半骑士进入方格(2,3),在方格(8,1)的半骑士进入方格(6,3)。 然后两个半骑士进入(4,5),但这个方格被认为是坏的,所以他们一起移动到方格(2,7)。 在第二块板上,半骑士们将永远不会见面。

题目描述

A boy Petya loves chess very much. He even came up with a chess piece of his own, a semiknight. The semiknight can move in any of these four directions: $ 2 $ squares forward and $ 2 $ squares to the right, $ 2 $ squares forward and $ 2 $ squares to the left, $ 2 $ squares backward and $ 2 $ to the right and $ 2 $ squares backward and $ 2 $ to the left. Naturally, the semiknight cannot move beyond the limits of the chessboard. Petya put two semiknights on a standard chessboard. Petya simultaneously moves with both semiknights. The squares are rather large, so after some move the semiknights can meet, that is, they can end up in the same square. After the meeting the semiknights can move on, so it is possible that they meet again. Petya wonders if there is such sequence of moves when the semiknights meet. Petya considers some squares bad. That is, they do not suit for the meeting. The semiknights can move through these squares but their meetings in these squares don't count. Petya prepared multiple chess boards. Help Petya find out whether the semiknights can meet on some good square for each board. Please see the test case analysis.

输入输出格式

输入格式


The first line contains number $ t $ ( $ 1<=t<=50 $ ) — the number of boards. Each board is described by a matrix of characters, consisting of 8 rows and 8 columns. The matrix consists of characters ".", "\#", "K", representing an empty good square, a bad square and the semiknight's position, correspondingly. It is guaranteed that matrix contains exactly $ 2 $ semiknights. The semiknight's squares are considered good for the meeting. The tests are separated by empty line.

输出格式


For each test, print on a single line the answer to the problem: "YES", if the semiknights can meet and "NO" otherwise.

输入输出样例

输入样例 #1

2
........
........
......#.
K..##..#
.......#
...##..#
......#.
K.......

........
........
..#.....
..#..#..
..####..
...##...
........
....K#K#

输出样例 #1

YES
NO

说明

Consider the first board from the sample. We will assume the rows and columns of the matrix to be numbered 1 through 8 from top to bottom and from left to right, correspondingly. The knights can meet, for example, in square ( $ 2 $ , $ 7 $ ). The semiknight from square ( $ 4 $ , $ 1 $ ) goes to square ( $ 2 $ , $ 3 $ ) and the semiknight goes from square ( $ 8 $ , $ 1 $ ) to square ( $ 6 $ , $ 3 $ ). Then both semiknights go to ( $ 4 $ , $ 5 $ ) but this square is bad, so they move together to square ( $ 2 $ , $ 7 $ ). On the second board the semiknights will never meet.

Input

题意翻译

### 题目描述 一个名叫彼佳的男孩非常喜欢国际象棋。他甚至发明出了一种棋——“半骑士”。半骑士可以在这四个方向中的任何一个方向移动:向右前方2个方格,向左前方2个方格,向左后方2个方格,向右后方2个方格(译注:类似中国象棋中的象),当然,半骑士不能走出棋盘。 彼佳在标准棋盘上放了两个半骑士并同时移动它们。棋盘相当大,所以经过一些移动后半骑士可能相遇,也就是说,它们最终可能会在同一个方格中,这称为一次会面。会面结束后,半骑士们可以继续前进,因此它们有可能再次见面。彼佳认为一些方格不好。也就是说,它们不适合会面。 半骑士们可以穿过这些方格,但他们在这些方格中的会面不计算在内。 彼佳准备了多个国际象棋棋盘。帮助彼佳找出半骑士是否可以在每个棋盘的某个好方格上相遇。 请结合测试数据分析。 ## 输入输出格式 ### 输入格式: 第一行包含数字t(1 <= t <= 50)——棋盘数量。 每个棋盘由一个字符矩阵描述,由8行和8列组成。矩阵由字符“.”,“#”与“K”组成,表示空的方格(好方格),坏方格和半骑士的位置。 保证矩阵恰好包含2个半骑士。半骑士们一开始所在的两个方格(输入“K”的地方)被看作好方格。每个矩阵之间用空行(回车)分隔。 ### 输出格式: 对于每个矩阵,只输出一行: 若半骑士们可以在某个好方格上会面,输出"YES"(不含引号),反之则输出"NO"。 ## 说明 我们将假设矩阵的行和列从上到下和从左到右编号为1到8。在第一块棋盘中,半骑士们可以在方格(2,7)中相遇。在方格(4,1)的半骑士进入方格(2,3),在方格(8,1)的半骑士进入方格(6,3)。 然后两个半骑士进入(4,5),但这个方格被认为是坏的,所以他们一起移动到方格(2,7)。 在第二块板上,半骑士们将永远不会见面。

加入题单

算法标签: