QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 256 MB مجموع النقاط: 100

#8467. 二进制字符串

الإحصائيات

给定 $n$ 个非空二进制字符串 $s_1, s_2, \dots, s_n$ 和另外 $m$ 个非空二进制字符串 $t_1, t_2, \dots, t_m$,判断是否存在一个二进制字符串 $S$ 满足:

  • 存在 $i$ 和 $j$ 使得 $1 \le i < j \le n$,且字符串 $s_i$ 和 $s_j$ 均作为子串出现在 $S$ 中。
  • 对于所有 $1 \le i \le m$,字符串 $t_i$ 均不作为子串出现在 $S$ 中。

输入格式

第一行包含一个整数 $T$ ($1 \le T \le 10^5$),表示测试用例的数量。每个测试用例:

第一行包含两个整数 $n$ 和 $m$ ($2 \le n \le 10^5, 1 \le m \le 10^5$)。 接下来 $n$ 行包含非空二进制字符串 $s_1, s_2, \dots, s_n$,每行一个。 接下来 $m$ 行包含非空二进制字符串 $t_1, t_2, \dots, t_m$,每行一个。

保证所有测试用例的 $\sum n + \sum m \le 10^5$ 且 $\sum |s_i| + \sum |t_i| \le 10^6$。

输出格式

对于每个测试用例,如果存在这样的二进制字符串 $S$,输出一行字符串 “Yes”(不含引号),否则输出 “No”(不含引号)。

样例

输入格式 1

2
3 2
100
001
010
1001
000
2 4
100
001
010
1001
000
11

输出格式 1

Yes
No

说明

对于第一个样例,一个可能的字符串是 “0100”,其中 $s_1 = 100$ 和 $s_3 = 010$ 出现在其中,但 $t_1 = 1001$ 和 $t_2 = 000$ 没有出现。

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.