3395: G.String Transformation
题目描述
Bobo has a string S = s1s2 . . . sn consists of letter a, b and c. He can transform the string by inserting or deleting substrings aa, bb and abab.
Formally, A = u ◦ w ◦ v (“◦” denotes string concatenation) can be transformed into A0 = u ◦ v and vice versa where u, v are (possibly empty) strings and w {aa, bb, abab}.
Given the target string T = t1t2 . . . tm, determine if Bobo can transform the string S into T .
输入
The input consists of several test cases and is terminated by end-of-file.
The first line of each test case contains a string s1s2 . . . sn. The second line contains a string t1t2 . . . tm.
输出
For each test case, print Yes if Bobo can. Print No otherwise.
Constraint
• 1 ≤ n, m ≤ 104
• s1, s2, . . . , sn, t1, t2, . . . , tm {a, b, c}
样例输入 复制
ab
ba
ac
ca
a
ab
样例输出 复制
Yes
No
No