/
実行時間制限: 2 sec / メモリ制限: 1024 MiB
配点 : 100 点
問題文
縦 2 行、横 2 列のグリッドがあります。
グリッドの各マスには A, B, C, D のいずれかがちょうど 1 つ書かれており、4 マスに書かれている文字は相異なります。
上から i 行目、左から j 列目のマスには S_{i,j} が書かれています。
A が書かれたマスと D が書かれたマスが隣接している、すなわち辺を共有しているならば Yes を、そうでないならば No を出力してください。
制約
- 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} は相異なる
入力
入力は以下の形式で標準入力から与えられる。
S_{1,1}S_{1,2}
S_{2,1}S_{2,2}
出力
答えを 1 行で出力せよ。
入力例 1
AB DC
出力例 1
Yes
A は上から 1 行目、左から 1 列目のマスに書かれています。
D は上から 2 行目、左から 1 列目のマスに書かれています。
この 2 マスは辺を共有しているため、隣接しています。
入力例 2
AB CD
出力例 2
No
入力例 3
BD CA
出力例 3
Yes
Score : 100 points
Problem Statement
There is a grid with 2 rows and 2 columns.
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}.
If the cell containing A and the cell containing D are adjacent, that is, they share an edge, print Yes; otherwise, print No.
Constraints
- S_{i,j} is one of
A,B,C, andD. - If (i_1,j_1)\neq (i_2,j_2), then S_{i_1,j_1} and S_{i_2,j_2} are distinct.
Input
The input is given from Standard Input in the following format:
S_{1,1}S_{1,2}
S_{2,1}S_{2,2}
Output
Print the answer in a single line.
Sample Input 1
AB DC
Sample 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.
Sample Input 2
AB CD
Sample Output 2
No
Sample Input 3
BD CA
Sample Output 3
Yes