102290: [AtCoder]ABC229 A - First Grid

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $100$ points

Problem Statement

We have a grid with $2$ horizontal rows and $2$ vertical columns.
Each of the squares is black or white, and there are at least $2$ black squares.
The colors of the squares are given to you as strings $S_1$ and $S_2$, as follows.

  • If the $j$-th character of $S_i$ is #, the square at the $i$-th row from the top and $j$-th column from the left is black.
  • If the $j$-th character of $S_i$ is ., the square at the $i$-th row from the top and $j$-th column from the left is white.

You can travel between two different black squares if and only if they share a side.
Determine whether it is possible to travel from every black square to every black square (directly or indirectly) by only passing black squares.

Constraints

  • Each of $S_1$ and $S_2$ is a string with two characters consisting of # and ..
  • $S_1$ and $S_2$ have two or more #s in total.

Input

Input is given from Standard Input in the following format:

$S_1$
$S_2$

Output

If it is possible to travel from every black square to every black square, print Yes; otherwise, print No.


Sample Input 1

##
.#

Sample Output 1

Yes

It is possible to directly travel between the top-left and top-right black squares and between top-right and bottom-right squares.
These two moves enable us to travel from every black square to every black square, so the answer is Yes.


Sample Input 2

.#
#.

Sample Output 2

No

It is impossible to travel between the top-right and bottom-left black squares, so the answer is No.

Input

题意翻译

### 题目描述 我们有一个 $2$ 行 $2$ 列的网格。 每一格都是黑色或者白色的,并保证网格内至少有 $2$ 个黑格。 网格的颜色用字符串 $S_1$ 和 $S_2$ 以下面的格式给出: - 如果 $S_i$ 的第 $j$ 个字符是 `#`,那么从上往下数第 $i$ 行、从左往右数第 $j$ 列的格子是黑色的。 - 如果 $S_i$ 的第 $j$ 个字符是 `.`,那么从上往下数第 $i$ 行、从左往右数第 $j$ 列的格子是白色的。 你可以在两块不同的并当且仅当它们有公共边的黑格之间行走。 判断是否可以只通过黑格(直接或者间接)从任意一个黑格走到另一个黑格。 ### 输入格式 输入以下述格式从标准输入给出: > $S_1$ $S_2$ ### 输出格式 如果可以从任意一个黑格走到另一个黑格,输出 `Yes`;否则输出 `No`。 ### 说明 / 提示 #### 约定 - $S_1$ 和 $S_2$ 都是长度为 $2$ 并且仅包含 `#` 和 `.` 的字符串。 - $S_1$ 和 $S_2$ 中 `#` 至少有 $2$ 个。 #### 样例 1 解释 你可以直接从左上角的黑格走到右上角的黑格,你还可以直接从右上角的黑格走到右下角的黑格。 这两个条件足以让我们从任意一个黑格走到另一个黑格,所以输出 `Yes`。 #### 样例 2 解释 你不可以从右上角的黑格走到左下角的黑格,所以输出 `No`。

Output

分数:100分

问题描述

我们有一个带有2行和2列的网格。
每个方块是黑色或白色,至少有2个黑色方块。
方块的颜色作为字符串$S_1$和$S_2$给你,如下所示。

  • 如果$S_i$的第$j$个字符是#,则从上数第$i$行,从左数第$j$列的方块是黑色。
  • 如果$S_i$的第$j$个字符是.,则从上数第$i$行,从左数第$j$列的方块是白色。

只有通过黑色方块,才能从一个不同的黑色方块旅行到另一个不同的黑色方块(直接或间接)
确定是否可以从每个黑色方块到达每个黑色方块(直接或间接)。

约束

  • $S_1$和$S_2$都是由#.组成的长度为2的字符串。
  • $S_1$和$S_2$总共由两个或多个#组成。

输入

输入从标准输入按以下格式给出:

$S_1$
$S_2$

输出

如果可以从每个黑色方块到达每个黑色方块,打印Yes;否则,打印No


样例输入1

##
.#

样例输出1

Yes

可以直接从左上角的黑色方块到右上角的黑色方块,从右上角到右下角的黑色方块。
这两个移动使我们能够从每个黑色方块到达每个黑色方块,所以答案是Yes


样例输入2

.#
#.

样例输出2

No

不可能从右上角的黑色方块到左下角的黑色方块,所以答案是No

加入题单

算法标签: