AtCoder Beginner Contest 259 - C - XX to XXX
Time Limit: 2 sec / Memory Limit: 1024 MB
Score :
Problem Statement
You are given two strings
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 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.
题目大意
你可以在字符串
通俗地讲,就是
问你
解题思路
用双指针分别记录
如果
1 |
|
否则(
要想在
- 如果
都为 ,就 ( 的 已由 拓展出来) - 否则,直接输出
No
并结束即可。
AC代码
1 |
|
同步发文于CSDN,原创不易,转载请附上原文链接哦~
Tisfy:https://letmefly.blog.csdn.net/article/details/125700254