atcoder#ABC259C. [ABC259C] XX to XXX

[ABC259C] XX to XXX

Score : 300300 points

Problem Statement

You are given two strings SS and TT. Determine whether it is possible to make SS equal TT by performing the following operation some number of times (possibly zero).

Between two consecutive equal characters in SS, insert a character equal to these characters. That is, take the following three steps.

  1. Let NN be the current length of SS, and S=S1S2SNS = S_1S_2\ldots S_N.
  2. Choose an integer ii between 11 and N1N-1 (inclusive) such that Si=Si+1S_i = S_{i+1}. (If there is no such ii, do nothing and terminate the operation now, skipping step 3.)
  3. Insert a single copy of the character Si(=Si+1)S_i(= S_{i+1}) between the ii-th and (i+1)(i+1)-th characters of SS. Now, SS is a string of length N+1N+1: S1S2SiSiSi+1SNS_1S_2\ldots S_i S_i S_{i+1} \ldots S_N.

Constraints

  • Each of SS and TT is a string of length between 22 and 2×1052 \times 10^5 (inclusive) consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

SS

TT

Output

If it is possible to make SS equal TT, print Yes; otherwise, print No. Note that the judge is case-sensitive.

abbaac
abbbbaaac
Yes

You can make S=S = abbaac equal T=T = abbbbaaac by the following three operations.

  • First, insert b between the 22-nd and 33-rd characters of SS. Now, S=S = abbbaac.
  • Next, insert b again between the 22-nd and 33-rd characters of SS. Now, S=S = abbbbaac.
  • Lastly, insert a between the 66-th and 77-th characters of SS. Now, S=S = abbbbaaac.

Thus, Yes should be printed.

xyzz
xyyzz
No

No sequence of operations makes S=S = xyzz equal T=T = xyyzz. Thus, No should be printed.