CF1898E.Sofia and Strings
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sofia has a string s of length n , consisting only of lowercase English letters. She can perform operations of the following types with this string.
- Select an index 1≤i≤∣s∣ and remove the character si from the string.
- Select a pair of indices (l,r) ( 1≤l≤r≤∣s∣ ) and sort the substring slsl+1…sr in alphabetical order.
Here, ∣s∣ denotes the current length of s . In particular, ∣s∣=n before the first operation. For example, if s=sofia , then performing the operation of the first type with i=4 results in s becoming sofa , and performing the operation of the second type with (l,r)=(2,4) after that results in s becoming safo .Sofia wants to obtain the string t of length m after performing zero or more operations on string s as described above. Please determine whether it is possible or not.
输入格式
The first line contains one integer t ( 1≤t≤10000 ) — the number of test cases.
The first line of each test case contains two integers n , m ( 1≤m≤n≤2⋅105 ) — the lengths of string s and t , respectively.
The second line of each test case contains the string s of length n , consisting only of lowercase English letters.
The third line of each test case contains the string t of length m , consisting only of lowercase English letters.
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, output "YES" if Sofia can obtain the string t from s using the operations above. Otherwise, output "NO".
You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.
输入输出样例
输入#1
8 5 5 sofia afios 3 2 cba bc 5 1 sofia e 15 7 anavolimilovana aamanan 26 4 abcdefghijklmnopqrstuvwxyz nope 26 4 zyxwvutsrqponmlkjihgfedcba nope 7 3 apricot cat 3 3 cba acb
输出#1
YES YES NO YES NO YES NO YES
说明/提示
In the first test case, Sofia can perform the following operation:
- operation of the second type with l=1 and r=5 : string s becomes afios after it.
In the second test case, Sofia can perform the following operations:
- operation of the second type with l=1 and r=2 : string s becomes bca after it;
- operation of the first type with i=3 : string s becomes bc after it.
In the third test case, it can be shown that it is impossible to obtain t from s using the provided operations.