CS240 project Problem 2
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
Problem Statement
You are presented with two primary strings: S and T, and a target string X of the same length as S, initially filled entirely with the character #. Your task is to determine if it's possible to transform X into S by repeatedly overlaying the string T onto X.
Constraints
- The string
Sis composed of letters and has a lengthN. - The string
Talso consists of letters and has a lengthM, whereMis less than or equal toN. Xis a string of lengthNfilled entirely with the character#.- You can overlay
Ton any part ofX, replacingMconsecutive characters, as many times as you want. - Given lengths: and .
Input
The input is given from Standard Input in the following format:
N M
S
T
Output
Print Yes if it is possible to make X match S; print No otherwise.
Sample Input 1
5 3
ABCBC
ABC
Sample Output 1
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.
Sample Input 2
7 3
ABBCABC
ABC
Sample Output 2
No
it's impossible to make match .
Sample Input 3
12 2
XYXXYXXYYYXY
XY
Sample Output 3
Yes
CS240 2024 Spring Project Problem
- Status
- Done
- Rule
- IOI
- Problem
- 4
- Start at
- 2024-5-30 17:00
- End at
- 2024-6-24 23:59
- Duration
- 607 hour(s)
- Host
- Partic.
- 99