Codeforces Round 910 (Div. 2)
E
Sofia and Strings
Codeforces
2200
原题
← DF →
翻译中…

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.

翻译中…
  1. Select an index $1 \le i \le |s|$ and remove the character $s_i$ from the string.
  2. 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.
翻译中…

Here, $|s|$ denotes the current length of $s$. In particular, $|s| = n$ before the first operation. For example, if $s = \mathtt{sofia}$, then performing the operation of the first type with $i=4$ results in $s$ becoming $\mathtt{sofa}$, and performing the operation of the second type with $(l, r) = (2, 4)$ after that results in $s$ becoming $\mathtt{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.

翻译中…

Input

翻译中…

The 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$.

翻译中…

Output

翻译中…

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.

翻译中…

Note

翻译中…

In the first test case, Sofia can perform the following operation:

翻译中…
  1. 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:

翻译中…
  1. operation of the second type with $l=1$ and $r=2$: string $s$ becomes $\mathtt{bca}$ after it;
  2. 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.

翻译中…

样例

Input #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
Output #1
YES
YES
NO
YES
NO
YES
NO
YES
InputCopy OutputCopy
题目信息
题号
1898E
时间限制
2 s
内存限制
256 MB
标签
数据结构
贪心
排序
字符串
双指针

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。