102321: [AtCoder]ABC232 B - Caesar Cipher

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $200$ points

Problem Statement

Takahashi has a string $S$ consisting of lowercase English letters.

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

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

Here,

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

For example, b shifted to the right by $4$ is f, and y shifted to the right by $3$ is b.

You are given a string $T$. Determine whether Takahashi can make $S$ equal $T$ by the operation above.

Constraints

  • Each of $S$ and $T$ is a string of length between $1$ and $10^5$ (inclusive) consisting of lowercase English letters.
  • The lengths of $S$ and $T$ are equal.

Input

Input is given from Standard Input in the following format:

$S$
$T$

Output

If Takahashi can make $S$ equal $T$, print Yes; if not, print No.


Sample Input 1

abc
ijk

Sample Output 1

Yes

When Takahashi chooses $K=8$,

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

and now $S$ and $T$ are equal.
Therefore, he can make $S$ equal $T$, so Yes should be printed.


Sample Input 2

z
a

Sample Output 2

Yes

Choosing $K=1$ makes $S$ and $T$ 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 $K$ that he can choose to make $S$ equal $T$, so No should be printed.


Sample Input 4

atcoder
atcoder

Sample Output 4

Yes

Choosing $K=0$ makes $S$ and $T$ equal.

Input

题意翻译

给定一个字符串 $s$,求能否通过位移 $k$ 位变成字符串 $t$。 位移:若 $k=1$,则 $a$ 位移成 $b$,$b$ 位移成 $c$,$\cdots$,$z$ 位移成 $a$。 Translated by ShanCreeper.

Output

得分:200分

问题描述

高桥君有一个由小写字母组成的字符串$S$。

在这个字符串上,他将只进行一次以下操作。

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

这里,

  • a向右移$1$位是b
  • b向右移$1$位是c
  • c向右移$1$位是d
  • ……
  • y向右移$1$位是b
  • z向右移$1$位是a

例如,b向右移$4$位是fy向右移$3$位是b

给你一个字符串$T$。判断高桥君是否可以通过上述操作使$S$等于$T$。

约束

  • $S$和$T$都是长度在$1$到$10^5$(含)之间的小写字母组成的字符串。
  • $S$和$T$的长度相等。

输入

从标准输入按以下格式获取输入:

$S$
$T$

输出

如果高桥君可以让$S$等于$T$,打印Yes;否则,打印No


样例输入1

abc
ijk

样例输出1

Yes

当高桥君选择$K=8$时,

  • a向右移$8$位变成i
  • b向右移$8$位变成j
  • c向右移$8$位变成k

现在$S$和$T$相等。
因此,他可以让$S$等于$T$,所以应该打印Yes


样例输入2

z
a

样例输出2

Yes

选择$K=1$使$S$和$T$相等。
请注意,z右边的字母是a


样例输入3

ppq
qqp

样例输出3

No

没有非负整数$K$可以使$S$等于$T$,所以应该打印No


样例输入4

atcoder
atcoder

样例输出4

Yes

选择$K=0$使$S$和$T$相等。

加入题单

算法标签: