AT_abc480_a.ADjacent

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

There is a grid with 22 rows and 22 columns.

Each cell of the grid contains exactly one of A, B, C, and D, and the characters written in the 44 cells are distinct. The cell at the ii-th row from the top and the jj-th column from the left contains Si,jS_{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.

有一个 22 行 22 列的网格。

网格的每个单元格中恰好包含 A、B、C、D 中的一个字符,且这 44 个单元格中的字符互不相同。位于从上往下第 ii 行、从左往右第 jj 列的单元格中包含字符 Si,jS_{i,j}。

如果包含 A 的单元格与包含 D 的单元格相邻(即它们有一条公共边),则输出 Yes;否则输出 No。

输入格式

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

S1,1S1,2S_{1,1}S_{1,2}
S2,1S2,2S_{2,1}S_{2,2}

输入从标准输入给出,格式如下:

S1,1S1,2S_{1,1}S_{1,2}
S2,1S2,2S_{2,1}S_{2,2}

输出格式

Print the answer in a single line.

在一行中输出答案。

输入输出样例

  • 输入#1

    AB
    DC

    输出#1

    Yes
  • 输入#2

    AB
    CD

    输出#2

    No
  • 输入#3

    BD
    CA

    输出#3

    Yes

说明/提示

Sample 1 Explanation:
A is written in the cell at the 11-st row from the top and the 11-st column from the left.
D is written in the cell at the 22-nd row from the top and the 11-st column from the left.
These 22 cells share an edge, so they are adjacent.

Constraints

  • Si,jS_{i,j} is one of A, B, C, and D.
  • If (i1,j1)≠(i2,j2)(i_1,j_1)\neq (i_2,j_2), then Si1,j1S_{i_1,j_1} and Si2,j2S_{i_2,j_2} are distinct.

样例 1 解释:
字符 A 写在从上往下数第 11 行、从左往右数第 11 列的格子中。
字符 D 写在从上往下数第 22 行、从左往右数第 11 列的格子中。
这两个格子有一条公共边,因此它们是相邻的。

约束条件

  • Si,jS_{i,j} 是 A、B、C、D 中的一个。
  • 若 (i1,j1)≠(i2,j2)(i_1,j_1)\neq (i_2,j_2),则 Si1,j1S_{i_1,j_1} 与 Si2,j2S_{i_2,j_2} 互不相同。

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

首页