

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 400 点
問題文
1, 2, 3 の番号がついた 3 人の高橋くんがおり、赤・緑・青の色がついた 3 種類の帽子がそれぞれ 1 つずつあります。それぞれの高橋くんは帽子を 1 つかぶっており、高橋くん i がはじめにかぶっている帽子の色は文字 S_i で表されます。ここで、R
は赤、G
は緑、B
は青に対応しています。これから、以下の操作をちょうど 10^{18} 回行います。
操作
- 3 人の高橋くんのうち 2 人を選ぶ。2 人はお互いのかぶっている帽子を交換する。
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
例えば、高橋くん 1 と高橋くん 2 の帽子を交換する操作を 10^{18} 回行うと目的を達成できます。
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.