

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
英大文字からなる長さ の文字列 と、英大文字からなる長さ の文字列 が与えられます。
#
のみからなる長さ の文字列 があります。
以下の操作を好きな回数行うことで、 を に一致させることができるか判定してください。
- の中から連続する 文字を選び、 で置き換える。
制約
- は英大文字からなる長さ の文字列
- は英大文字からなる長さ の文字列
入力
入力は以下の形式で標準入力から与えられる。
出力
を に一致させることができるならば Yes
を、できないならば No
を出力せよ。
入力例 1Copy
7 3 ABCBABC ABC
出力例 1Copy
Yes
以下、 の 文字目から 文字目までの部分を と表記します。
次のように操作を行うことで、 を に一致させることができます。
- を で置き換える。
##ABC##
になる。 - を で置き換える。
ABCBC##
になる。 - を で置き換える。
ABCBABC
になる。
入力例 2Copy
7 3 ABBCABC ABC
出力例 2Copy
No
どのように操作を行っても、 を に一致させることはできません。
入力例 3Copy
12 2 XYXXYXXYYYXY XY
出力例 3Copy
Yes
Score : points
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 1Copy
7 3 ABCBABC ABC
Sample Output 1Copy
Yes
Below, let denote the part from the -th through the -th character of .
You can make match by operating as follows.
- Replace with . becomes
##ABC##
. - Replace with . becomes
ABCBC##
. - Replace with . becomes
ABCBABC
.
Sample Input 2Copy
7 3 ABBCABC ABC
Sample Output 2Copy
No
No matter how you operate, it is impossible to make match .
Sample Input 3Copy
12 2 XYXXYXXYYYXY XY
Sample Output 3Copy
Yes