AtCoder Talent Quest 〜现在就让28届毕业生逃脱吧〜预选赛 #2(第 480 场 AtCoder Beginner Contest)
A
相邻
ADjacent
AtCoder
⌀ 0
原题
←B →

相邻AI (CI翻译)

Problem Statement

题目描述

AI (CI翻译)

There is a grid with $2$ rows and $2$ columns.

有一个 $2$ 行 $2$ 列的网格。AI (CI翻译)

Each cell of the grid contains exactly one of A, B, C, and D, and the characters written in the $4$ cells are distinct. The cell at the $i$-th row from the top and the $j$-th column from the left contains $S_{i,j}$.

网格的每个格子中恰好包含 A、B、C、D 中的一个字符,且 $4$ 个格子中的字符各不相同。从上往下第 $i$ 行、从左往右第 $j$ 列的格子中包含字符 $S_{i,j}$。AI (CI翻译)

If the cell containing A and the cell containing D are adjacent, that is, they share an edge, print Yes; otherwise, print No.

如果包含 A 的格子与包含 D 的格子相邻,也就是说,它们共用一条边,则输出 Yes;否则,输出 No。AI (CI翻译)

Constraints

约束条件

AI (CI翻译)
  • $S_{i,j}$ is one of A, B, C, and D.
  • If $(i_1,j_1)\neq (i_2,j_2)$, then $S_{i_1,j_1}$ and $S_{i_2,j_2}$ are distinct.
  • $S_{i,j}$ 是 A、B、C、D 之一。
  • 如果 $(i_1,j_1)\neq (i_2,j_2)$,则 $S_{i_1,j_1}$ 和 $S_{i_2,j_2}$ 不同。
AI (CI翻译)

Input

输入格式

AI (CI翻译)

The input is given from Standard Input in the following format:

输入从标准输入按以下格式给出:AI (CI翻译)

S_{1,1}S_{1,2}
S_{2,1}S_{2,2}

S_{1,1}S_{1,2}
S_{2,1}S_{2,2}
AI (CI翻译)

Output

输出格式

AI (CI翻译)

Print the answer in a single line.

在一行中输出答案。AI (CI翻译)

样例

Input #1
AB
DC
Output #1
Yes
`A` is written in the cell at the $1$-st row from the top and the $1$-st column from the left. `D` is written in the cell at the $2$-nd row from the top and the $1$-st column from the left. These $2$ cells share an edge, so they are adjacent.
Input #2
AB
CD
Output #2
No
Input #3
BD
CA
Output #3
Yes

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。