#abc244d. D - Swap Hats
D - Swap Hats
Score : points
问题描述
有三位编号分别为 、 和 的高桥,以及三顶颜色分别为红色、绿色和蓝色的帽子。每位高桥都戴了一顶帽子。高桥 当前所戴帽子的颜色由字符 表示。其中,R
对应红色,G
对应绿色,B
对应蓝色。现在,他们将 精确地 进行 次以下操作。
操作
- 从三位高桥中选择两位。这两位交换他们所戴的帽子。
在经过 次重复操作后,是否可能使高桥 戴上对应于字符 颜色的帽子?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There are three Takahashis numbered , and , and three hats colored red, green, and blue. Each Takahashi is wearing one hat. The color of the hat that Takahashi is currently wearing is represented by a character . Here, R
corresponds to red, G
to green, and B
to blue. Now, they will do the following operation exactly times.
Operation
- Choose two out of the three Takahashis. The two exchange the hats they are wearing.
Is it possible to make Takahashi wearing the hat of color corresponding to character after the repetitions?
Constraints
- are a permutation of
R
,G
,B
. - are a permutation of
R
,G
,B
.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make Takahashi wearing the hat of color corresponding to character after the 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 times the operation of swapping the hats of Takahashi and Takahashi .
update @ 2024/3/10 10:29:08