

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 200 点
問題文
高橋君は英小文字からなる文字列 S を持っています。
高橋君は文字列 S に対して、下記の操作をちょうど 1 回行います。
- まず、非負整数 K を選ぶ。
- その後、S の各文字を K 個後ろの英小文字に変更する。
ただし、
a
の 1 個後ろの英小文字はb
であり、b
の 1 個後ろの英小文字はc
であり、c
の 1 個後ろの英小文字はd
であり、- \cdots
y
の 1 個後ろの英小文字はz
であり、z
の 1 個後ろの英小文字はa
です。
例えば、b
の 4 個後ろの英小文字は f
であり、y
の 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
の 1 個後ろの英小文字は a
であることに注意してください。
入力例 3
ppq qqp
出力例 3
No
高橋君は非負整数 K をどのように選んでも S を T に一致させることができません。
よって、No
と出力します。
入力例 4
atcoder atcoder
出力例 4
Yes
高橋君が K=0 を選ぶと S と T が一致します。
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 isb
;b
shifted to the right by 1 isc
;c
shifted to the right by 1 isd
;- \cdots
y
shifted to the right by 1 isz
;z
shifted to the right by 1 isa
.
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 becomesi
,b
is shifted to the right by 8 and becomesj
,c
is shifted to the right by 8 and becomesk
,
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.