102443: [AtCoder]ABC244 D - Swap Hats
Description
Score : $400$ points
Problem Statement
There are three Takahashis numbered $1$, $2$ and $3$, and three hats colored red, green, and blue. Each Takahashi is wearing one hat. The color of the hat that Takahashi $i$ is currently wearing is represented by a character $S_i$. Here, R
corresponds to red, G
to green, and B
to blue. Now, they will do the following operation exactly $10^{18}$ times.
Operation
- Choose two out of the three Takahashis. The two exchange the hats they are wearing.
Is it possible to make Takahashi $i$ wearing the hat of color corresponding to character $T_i$ after the $10^{18}$ repetitions?
Constraints
- $S_1, S_2, S_3$ are a permutation of
R
,G
,B
. - $T_1, T_2, T_3$ are a permutation of
R
,G
,B
.
Input
Input is given from Standard Input in the following format:
$S_1$ $S_2$ $S_3$ $T_1$ $T_2$ $T_3$
Output
If it is possible to make Takahashi $i$ wearing the hat of color corresponding to character $T_i$ after the $10^{18}$ repetitions, print Yes
; otherwise, print No
.
Sample Input 1
R G B R G B
Sample Output 1
Yes
For example, the objective can be achieved by repeating $10^{18}$ times the operation of swapping the hats of Takahashi $1$ and Takahashi $2$.
Input
Output
问题描述
有三个编号为$1$,$2$和$3$的高桥,以及三顶红色,绿色和蓝色的帽子。每个高桥都戴了一顶帽子。高桥$i$当前所戴帽子的颜色用字符$S_i$表示。其中,R
表示红色,G
表示绿色,B
表示蓝色。现在,他们将执行以下操作恰好$10^{18}$次。
操作
- 从三个高桥中选择两个。两人互换所戴的帽子。
在$10^{18}$次重复后,有可能让高桥$i$戴上与字符$T_i$相对应颜色的帽子吗?
约束条件
- $S_1, S_2, S_3$是
R
,G
,B
的一个排列。 - $T_1, T_2, T_3$是
R
,G
,B
的一个排列。
输入
从标准输入按以下格式获取输入:
$S_1$ $S_2$ $S_3$ $T_1$ $T_2$ $T_3$
输出
如果在$10^{18}$次重复后,有可能让高桥$i$戴上与字符$T_i$相对应颜色的帽子,则打印Yes
;否则,打印No
。
样例输入1
R G B R G B
样例输出1
Yes
例如,可以通过重复$10^{18}$次交换高桥$1$和高桥$2$的帽子的操作来实现目标。