题库练习 Two 0-1 Sequences
← 上一题 下一题 →

A15212 | Two 0-1 Sequences

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

AquaMoon has two binary sequences $a$ and $b$ , which contain only $0$ and $1$ . AquaMoon can perform the following two operations any number of times ( $a_1$ is the first element of $a$ , $a_2$ is the second element of $a$ , and so on):

- Operation 1: if $a$ contains at least two elements, change $a_2$ to $\operatorname{min}(a_1,a_2)$ , and remove the first element of $a$ .
- Operation 2: if $a$ contains at least two elements, change $a_2$ to $\operatorname{max}(a_1,a_2)$ , and remove the first element of $a$ .

Note that after a removal of the first element of $a$ , the former $a_2$ becomes the first element of $a$ , the former $a_3$ becomes the second element of $a$ and so on, and the length of $a$ reduces by one.

Determine if AquaMoon can make $a$ equal to $b$ by using these operations.

输入格式

The first line contains a single integer $t$ ( $1 \leq t \leq 2\,000$ ) — the number of test cases. Description of test cases follows.

The first line of each test case contains two integers $n$ , $m$ ( $1 \leq n,m \leq 50$ , $m \leq n$ ) — the lengths of $a$ and $b$ respectively.

The second line of each test case contains a string $a$ of length $n$ , consisting only $0$ and $1$ .

The third line of each test case contains a string $b$ of length $m$ , consisting only $0$ and $1$ .

输出格式

For each test case, output "YES" if AquaMoon can change $a$ to $b$ by using these options; otherwise, output "NO".

You may print each letter in any case (for example, "YES", "Yes", "yes", "yEs" will all be recognized as a positive answer).

输入输出样例

输入 #1
10
6 2
001001
11
6 2
110111
01
6 2
000001
11
6 2
111111
01
8 5
10000101
11010
7 4
1010001
1001
8 6
01010010
010010
8 4
01010101
1001
8 4
10101010
0110
7 5
1011100
11100
输出 #1
YES
YES
NO
NO
NO
YES
YES
NO
NO
YES
C++ 编辑器
输入
输出