#P13549. 热辣滚烫

    ID: 11593 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>字符串洛谷原创O2优化洛谷月赛

热辣滚烫

Description

Little L abstracts the plot of movie A as a string s1s_1 of length nn.

Little L abstracts the plot of movie B as a string s2s_2 of length mm.

If Little L can insert any string (which can be empty) either before s1s_1 or after any character in s1s_1 to obtain a new string s1{s_1}' such that s1=s2{s_1}' = s_2, then we say movie B is "Yolo".

Little L has a total of TT queries. For each query, you need to determine whether movie B is "Yolo". If yes, output Yes; otherwise, output No.

Input Format

This problem contains multiple test cases.

The first line contains a positive integer TT, the number of test cases.

For each test case:

  • The first line contains two positive integers nn and mm, separated by a space, representing the lengths of strings s1s_1 and s2s_2.
  • The second line contains the string s1s_1.
  • The third line contains the string s2s_2.

Output Format

Output TT lines, each containing either Yes or No, indicating whether movie B is "Yolo".

9
3 4
aab
aabb
3 5
xyz
xabyz
3 5
xyz
axbyz
4 4
aabb
aabb
3 3
aab
abb
4 6
abgd
xyabgd
4 6
abgd
abgdgd
3 6
abb
aabbab
3 6
abb
aabbbb
Yes
Yes
No
Yes
No
Yes
Yes
No
Yes

Hint

Explanation of Sample 1:

For the first test case, you can insert the string b after the last character of s1s_1 to get s1=aabb{s_1}' = \texttt{aabb}.

For the second test case, you can insert the string ab after the first character of s1s_1 to get s1=xabyz{s_1}' = \texttt{xabyz}.

For the third test case, it can be proven that no such operation exists to make s1=s2{s_1}' = s_2.

For the fourth test case, you can insert an empty string after the third character of s1s_1 to get s1=aabb{s_1}' = \texttt{aabb}.

For the sixth test case, you can insert the string xy before s1s_1 to get s1=xyabgd{s_1}' = \texttt{xyabgd}.

Constraints

Test Case nn mm Special Property
11 103\leq 10^3 103\leq 10^3 A
22 =1=1 None
33 103\leq 10^3 B
464\sim 6 None
7107\sim 10 105\leq 10^5

Special Property A: n=mn = m.

Special Property B: n=m1n = m - 1.

For 100%100\% of the test cases:

  • 1T101 \leq T \leq 10,
  • 1nm1051 \leq n \leq m \leq 10^5,
  • Strings s1s_1 and s2s_2 consist of lowercase letters only.

Generated by Deepseek V3.