310845: CF1898E. Sofia and Strings
Description
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 \le i \le |s|$ and remove the character $s_i$ from the string.
- Select a pair of indices $(l, r)$ ($1 \le l \le r \le |s|$) and sort the substring $s_{l} s_{l+1} \ldots s_r$ in alphabetical order.
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.
InputThe first line contains one integer $t$ ($1 \leq t \leq 10\,000$) — the number of test cases.
The first line of each test case contains two integers $n$, $m$ ($1\leq m \leq n \leq 2\cdot 10^5$) — 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\cdot 10^5$.
OutputFor 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.
ExampleInput8 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 acbOutput
YES YES NO YES NO YES NO YESNote
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 $\mathtt{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 $\mathtt{bca}$ after it;
- operation of the first type with $i=3$: string $s$ becomes $\mathtt{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.
Output
Sofia有一个只包含小写英文字母的字符串s,可以对它执行两种操作:1. 删除s的一个字符;2. 对s的一个子串进行字典序排序。问能否通过这两种操作,将s变为另一个字符串t。
输入数据格式:
第一行包含一个整数t,表示测试用例的数量。
每个测试用例包含三行:
第一行包含两个整数n和m(1≤m≤n≤2×10^5),分别表示字符串s和t的长度。
第二行包含一个长度为n的字符串s。
第三行包含一个长度为m的字符串t。
输出数据格式:
对于每个测试用例,如果可以通过上述操作将s变为t,则输出"YES",否则输出"NO"。输出大小写不敏感。题目大意: Sofia有一个只包含小写英文字母的字符串s,可以对它执行两种操作:1. 删除s的一个字符;2. 对s的一个子串进行字典序排序。问能否通过这两种操作,将s变为另一个字符串t。 输入数据格式: 第一行包含一个整数t,表示测试用例的数量。 每个测试用例包含三行: 第一行包含两个整数n和m(1≤m≤n≤2×10^5),分别表示字符串s和t的长度。 第二行包含一个长度为n的字符串s。 第三行包含一个长度为m的字符串t。 输出数据格式: 对于每个测试用例,如果可以通过上述操作将s变为t,则输出"YES",否则输出"NO"。输出大小写不敏感。