重点单词:
piece n.个,块,片,零件,部分,点;
verify v.核实,查证,证明;
configuration n.布局,构造,配置;
identical adj.完全相同的,同一的;
出处:https://acs.jxnu.edu.cn/problem/NOIOPJCH0205200
Solitaire
5000ms 1000K
描述:
Solitaire is a game played on a chessboard 8x8. The rows and columns of the chessboard are numbered from 1 to 8, from the top to the bottom and from left to right respectively. 跳棋是一个在8*8的棋盘上玩的游戏。在棋盘上,每一行,每一列都分别从左到右,从上到下被标上了0--8的数字序号。There are four identical pieces on the board. In one move it is allowed to: 棋盘上有四块完全相同的棋子。在一步移动中它允许作如下操作:
- move a piece to an empty neighboring field (up, down, left or right),
- 移动一个棋子到相邻的空棋盘点;
- jump over one neighboring piece to an empty field (up, down, left or right).
- 跳过相邻的棋子到空棋盘点;
There are 4 moves allowed for each piece in the configuration shown above. As an example let's consider a piece placed in the row 4, column 4. It can be moved one row up, two rows down, one column left or two columns right.
Write a program that:
在上面所示的配置中,每个棋子允许上述4种移动。作为一个例子,让我们考虑放置在行4、列4中的一个片段。它可以向上移动一行、向下移动两行、向左移动一列或向右移动两列。
编写一个程序:
- reads two chessboard configurations from the standard input,
- verifies whether the second one is reachable from the first one in at most 8 moves,
- writes the result to the standard output.
-
从标准输入读取两个棋盘配置,
-
验证在最多8个移动中是否可以从第一个到达第二个,
-
将结果写入标准输出。
输入:
Each of two input lines contains 8 integers a1, a2, ..., a8 separated by single spaces and describes one configuration of pieces on the chessboard. Integers a2j-1 and a2j (1 <= j <= 4) describe the position of one piece -- the row number and the column number respectively.输出:
The output should contain one word YES if a configuration described in the second input line is reachable from the configuration described in the first input line in at most 8 moves, or one word NO otherwise.样例输入:
4 4 4 5 5 4 6 5 2 4 3 3 3 6 4 6
样例输出:
YES