#abc329e. E - Stamp
E - Stamp
Score : points
问题描述
你已知两个字符串:,由大写英文字母组成,长度为 ;以及 ,同样由大写英文字母组成,长度为 。
存在一个长度为 的字符串 ,仅由字符 #
组成。请确定是否可以通过执行以下操作任意次数,使 与 匹配:
- 在 中选择连续的 个字符,并用 替换它们。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given two strings: , which consists of uppercase English letters and has length , and , which also consists of uppercase English letters and has length .
There is a string of length consisting only of the character #
. Determine whether it is possible to make match by performing the following operation any number of times:
- Choose consecutive characters in and replace them with .
Constraints
- is a string consisting of uppercase English letters with length .
- is a string consisting of uppercase English letters with length .
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if it is possible to make match ; print No
otherwise.
Sample Input 1
7 3
ABCBABC
ABC
Sample Output 1
Yes
Below, let X\[l:r\] denote the part from the -th through the -th character of .
You can make match by operating as follows.
- Replace X\[3:5\] with . becomes
##ABC##
. - Replace X\[1:3\] with . becomes
ABCBC##
. - Replace X\[5:7\] with . becomes
ABCBABC
.
Sample Input 2
7 3
ABBCABC
ABC
Sample Output 2
No
No matter how you operate, it is impossible to make match .
Sample Input 3
12 2
XYXXYXXYYYXY
XY
Sample Output 3
Yes
update @ 2024/3/10 01:54:27