CF645A.Amity Assessment

普及-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Bessie the cow and her best friend Elsie each received a sliding puzzle on Pi Day. Their puzzles consist of a 2 × 2 grid and three tiles labeled 'A', 'B', and 'C'. The three tiles sit on top of the grid, leaving one grid cell empty. To make a move, Bessie or Elsie can slide a tile adjacent to the empty cell into the empty cell as shown below:

In order to determine if they are truly Best Friends For Life (BFFLs), Bessie and Elsie would like to know if there exists a sequence of moves that takes their puzzles to the same configuration (moves can be performed in both puzzles). Two puzzles are considered to be in the same configuration if each tile is on top of the same grid cell in both puzzles. Since the tiles are labeled with letters, rotations and reflections are not allowed.

奶牛贝茜和她最好的朋友埃尔西在圆周率日各自收到了一个滑块拼图。她们的拼图均由一个 2×22 \times 2 的网格和三块分别标有字母 'A'、'B' 和 'C' 的方块组成。这三块方块置于网格之上,恰好留出一个空格。每次移动时,贝茜或埃尔西可将与空格相邻的一块方块滑入该空格,如下图所示:

为了确认她们是否真的是“终生最佳挚友”(BFFL),贝茜和埃尔西想知道:是否存在一系列移动操作,使得她们各自的拼图最终达到相同的构型(两个拼图均可独立进行移动)。当且仅当每个字母方块均位于两个拼图中相同位置的网格单元格上时,才认为两个拼图处于同一构型。由于方块上标有特定字母,因此不允许通过旋转或翻转来等价判定构型。

输入格式

The first two lines of the input consist of a 2 × 2 grid describing the initial configuration of Bessie's puzzle. The next two lines contain a 2 × 2 grid describing the initial configuration of Elsie's puzzle. The positions of the tiles are labeled 'A', 'B', and 'C', while the empty cell is labeled 'X'. It's guaranteed that both puzzles contain exactly one tile with each letter and exactly one empty position.

输入的前两行构成一个 2×22 \times 2 的网格,描述贝茜谜题的初始状态;接下来的两行构成另一个 2×22 \times 2 的网格,描述埃尔西谜题的初始状态。方块的位置用字母 'A'、'B' 和 'C' 标记,空格位置用 'X' 标记。保证两个谜题中均恰好包含一个 'A'、一个 'B'、一个 'C' 和一个空格。

输出格式

Output "YES"(without quotes) if the puzzles can reach the same configuration (and Bessie and Elsie are truly BFFLs). Otherwise, print "NO" (without quotes).

如果两个谜题可以达到相同的构型(即贝茜和埃尔西确实是最好的朋友),则输出 "YES"(不带引号);否则,输出 "NO"(不带引号)。

输入输出样例

  • 输入#1

    AB
    XC
    XB
    AC

    输出#1

    YES
  • 输入#2

    AB
    XC
    AC
    BX

    输出#2

    NO

说明/提示

The solution to the first sample is described by the image. All Bessie needs to do is slide her 'A' tile down.

In the second sample, the two puzzles can never be in the same configuration. Perhaps Bessie and Elsie are not meant to be friends after all...

第一个样例的解法如图所示。贝茜只需将她的 'A' 方块向下滑动即可。

在第二个样例中,这两个谜题永远无法达到相同的构型。或许贝茜和埃尔西终究不是命中注定的朋友……

输入解题思路,AI测评打分。不知道怎么写?

首页