#abc259c. C - XX to XXX
C - XX to XXX
Score : points
问题描述
给定两个字符串 和 。确定是否可以通过执行以下操作一定次数(可能为零次)来使 等于 。
在 中任意两个连续相等的字符之间插入一个与这些字符相等的字符。具体步骤如下:
- 记 为当前字符串 的长度,即 。
- 选择一个整数 ,满足 (包含两端点),且 。(如果没有这样的 ,则无需进行任何操作,并立即终止该操作,跳过步骤3。)
- 在 的第 个和第 个字符之间插入一个与 相同的字符副本。现在, 变为长度为 的字符串:。
以上为通义千问 qwen-max 翻译,仅供参考。
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.
Sample Input 1
abbaac
abbbbaaac
Sample Output 1
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.
Sample Input 2
xyzz
xyyzz
Sample Output 2
No
No sequence of operations makes xyzz
equal xyyzz
. Thus, No
should be printed.
update @ 2024/3/10 10:59:26