QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 256 MB 총점: 100 해킹 가능 ✓

#17290. 青山喜欢字符串

통계

青山有一个字符串 $s$,而 Daniel 有一个字符串 $t$。两个字符串都仅包含 01

一个长度为 $k$ 的字符串 $a$ 是好的,当且仅当对于所有 $i = 1, 2, \dots, k - 1$,都有 $a_i \neq a_{i+1}$。

例如,11010101 是好的,而 111001001100 不是好的。

青山想要让 $s$ 变成好的。为此,她可以进行以下操作任意次(可能为零次):

  • 将 $t$ 插入到 $s$ 的任意位置(从而得到一个新的 $s$)。

请告诉青山是否有可能让 $s$ 变成好的。

输入格式

输入由多个测试用例组成。第一行包含一个整数 $T$ ($1 \le T \le 2000$) — 测试用例的数量。接下来是测试用例的描述。

每个测试用例的第一行包含两个整数 $n$ 和 $m$ ($1 \le n, m \le 50$) — 分别为字符串 $s$ 和 $t$ 的长度。

每个测试用例的第二行包含一个长度为 $n$ 的字符串 $s$。

每个测试用例的第三行包含一个长度为 $m$ 的字符串 $t$。

保证 $s$ 和 $t$ 仅包含 01

输出格式

对于每个测试用例,如果可以使 $s$ 变成好的,则输出 "YES"(不带引号),否则输出 "NO"(不带引号)。

你可以输出任意大小写的字母(大写或小写)。

样例

样例输入 1

5
1 1
1
0
3 3
111
010
3 2
111
00
6 7
101100
1010101
10 2
1001001000
10

样例输出 1

Yes
Yes
No
No
No

说明

在第一个测试用例中,$s$ 最初就是好的,因此你可以通过进行零次操作来获得一个好的 $s$。

在第二个测试用例中,你可以进行以下两次操作(插入的字符串 $t$ 带有下划线):

  1. $1\underline{010}11$
  2. $10101\underline{010}1$

从而得到 $s = 101010101$,它是好的。

在第三个测试用例中,无论进行多少次操作,都无法使 $s$ 变成好的。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.