310905: CF1907A. Rook
Description
As you probably know, chess is a game that is played on a board with 64 squares arranged in an $8\times 8$ grid. Columns of this board are labeled with letters from a to h, and rows are labeled with digits from 1 to 8. Each square is described by the row and column it belongs to.
The rook is a piece in the game of chess. During its turn, it may move any non-zero number of squares horizontally or vertically. Your task is to find all possible moves for a rook on an empty chessboard.
InputThe first line of input contains single integer $t$ ($1 \le t \le 64$) — the number of test cases. The descriptions of test cases follow.
Each test case contains one string of two characters, description of the square where rook is positioned. The first character is a letter from a to h, the label of column, and the second character is a digit from 1 to 8, the label of row.
The same position may occur in more than one test case.
OutputFor each test case, output descriptions of all squares where the rook can move, in the same format as in the input.
You can output squares in any order per test case.
ExampleInput1 d5Output
d1 d2 b5 g5 h5 d3 e5 f5 d8 a5 d6 d7 c5 d4
Output
输入数据格式:第一行输入一个整数 t(1 ≤ t ≤ 64),表示测试用例的数量。接下来每行包含一个由两个字符组成的字符串,描述车所在的方格。第一个字符是小写字母 a 到 h,代表列标签;第二个字符是数字 1 到 8,代表行标签。
输出数据格式:对于每个测试用例,按输入格式输出车可以移动到的所有方格的描述。每个测试用例的输出方格顺序可以是任意的。题目大意:在国际象棋中,车(rook)是一种棋子,它可以在其回合内沿水平或垂直方向移动任意数量的方格。任务是找出一个车在空棋盘上所有可能的移动位置。 输入数据格式:第一行输入一个整数 t(1 ≤ t ≤ 64),表示测试用例的数量。接下来每行包含一个由两个字符组成的字符串,描述车所在的方格。第一个字符是小写字母 a 到 h,代表列标签;第二个字符是数字 1 到 8,代表行标签。 输出数据格式:对于每个测试用例,按输入格式输出车可以移动到的所有方格的描述。每个测试用例的输出方格顺序可以是任意的。