#abc232b. B - Caesar Cipher

B - Caesar Cipher

Score : 200200 points

问题描述

Takahashi 拥有一个由小写英文字母组成的字符串 SS

他将在该字符串上执行以下操作一次。

  • 首先,选择一个非负整数 KK
  • 然后,将 SS 中的每个字符向右移动 KK 位(见下文)。

这里,

  • a 向右移动 11 位是 b
  • b 向右移动 11 位是 c
  • c 向右移动 11 位是 d
  • \cdots
  • y 向右移动 11 位是 z
  • z 向右移动 11 位是 a

例如,b 向右移动 44 位是 f,而 y 向右移动 33 位是 b

已给出一个字符串 TT。确定 Takahashi 是否可以通过上述操作使 SS 等于 TT

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

Problem Statement

Takahashi has a string SS consisting of lowercase English letters.

On this string, he will do the operation below just once.

  • First, choose a non-negative integer KK.
  • Then, shift each character of SS to the right by KK (see below).

Here,

  • a shifted to the right by 11 is b;
  • b shifted to the right by 11 is c;
  • c shifted to the right by 11 is d;
  • \cdots
  • y shifted to the right by 11 is z;
  • z shifted to the right by 11 is a.

For example, b shifted to the right by 44 is f, and y shifted to the right by 33 is b.

You are given a string TT. Determine whether Takahashi can make SS equal TT by the operation above.

Constraints

  • Each of SS and TT is a string of length between 11 and 10510^5 (inclusive) consisting of lowercase English letters.
  • The lengths of SS and TT are equal.

Input

Input is given from Standard Input in the following format:

SS

TT

Output

If Takahashi can make SS equal TT, print Yes; if not, print No.

Sample Input 1

abc
ijk

Sample Output 1

Yes

When Takahashi chooses K=8K=8,

  • a is shifted to the right by 88 and becomes i,
  • b is shifted to the right by 88 and becomes j,
  • c is shifted to the right by 88 and becomes k,

and now SS and TT are equal.
Therefore, he can make SS equal TT, so Yes should be printed.

Sample Input 2

z
a

Sample Output 2

Yes

Choosing K=1K=1 makes SS and TT equal.
Note that the letter on the right of z is a.

Sample Input 3

ppq
qqp

Sample Output 3

No

There is no non-negative integer KK that he can choose to make SS equal TT, so No should be printed.

Sample Input 4

atcoder
atcoder

Sample Output 4

Yes

Choosing K=0K=0 makes SS and TT equal.

update @ 2024/3/10 10:06:07