#abc244d. D - Swap Hats

D - Swap Hats

Score : 400400 points

问题描述

有三位编号分别为 112233 的高桥,以及三顶颜色分别为红色、绿色和蓝色的帽子。每位高桥都戴了一顶帽子。高桥 ii 当前所戴帽子的颜色由字符 SiS_i 表示。其中,R 对应红色,G 对应绿色,B 对应蓝色。现在,他们将 精确地 进行 101810^{18} 次以下操作。

操作

  • 从三位高桥中选择两位。这两位交换他们所戴的帽子。

在经过 101810^{18} 次重复操作后,是否可能使高桥 ii 戴上对应于字符 TiT_i 颜色的帽子?

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

There are three Takahashis numbered 11, 22 and 33, and three hats colored red, green, and blue. Each Takahashi is wearing one hat. The color of the hat that Takahashi ii is currently wearing is represented by a character SiS_i. Here, R corresponds to red, G to green, and B to blue. Now, they will do the following operation exactly 101810^{18} times.

Operation

  • Choose two out of the three Takahashis. The two exchange the hats they are wearing.

Is it possible to make Takahashi ii wearing the hat of color corresponding to character TiT_i after the 101810^{18} repetitions?

Constraints

  • S1,S2,S3S_1, S_2, S_3 are a permutation of R, G, B.
  • T1,T2,T3T_1, T_2, T_3 are a permutation of R, G, B.

Input

Input is given from Standard Input in the following format:

S1S_1 S2S_2 S3S_3

T1T_1 T2T_2 T3T_3

Output

If it is possible to make Takahashi ii wearing the hat of color corresponding to character TiT_i after the 101810^{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 101810^{18} times the operation of swapping the hats of Takahashi 11 and Takahashi 22.

update @ 2024/3/10 10:29:08