atcoder#ABC259C. [ABC259C] XX to XXX
[ABC259C] XX to XXX
Score : points
Problem Statement
You are given two strings and . Determine whether it is possible to make equal by performing the following operation some number of times (possibly zero).
Between two consecutive equal characters in , insert a character equal to these characters. That is, take the following three steps.
- Let be the current length of , and .
- Choose an integer between and (inclusive) such that . (If there is no such , do nothing and terminate the operation now, skipping step 3.)
- Insert a single copy of the character between the -th and -th characters of . Now, is a string of length : .
Constraints
- Each of and is a string of length between and (inclusive) consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
If it is possible to make equal , print Yes
; otherwise, print No
.
Note that the judge is case-sensitive.
abbaac
abbbbaaac
Yes
You can make abbaac
equal abbbbaaac
by the following three operations.
- First, insert
b
between the -nd and -rd characters of . Now,abbbaac
. - Next, insert
b
again between the -nd and -rd characters of . Now,abbbbaac
. - Lastly, insert
a
between the -th and -th characters of . Now,abbbbaaac
.
Thus, Yes
should be printed.
xyzz
xyyzz
No
No sequence of operations makes xyzz
equal xyyzz
.
Thus, No
should be printed.