Logo
(追記) (追記ここまで)

33440번 - Binary Strings 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 2048 MB1000.000%

문제

Given $n$ non-empty binary strings $s_1, s_2, \ldots, s_n$ and another $m$ non-empty binary strings $t_1, t_2, \ldots, t_m,ドル determine if there exists such a binary string $S$ that:

  • There exist $i$ and $j$ such that 1ドル \le i < j \le n,ドル and both strings $s_i$ and $s_j$ appear in $S$ as substrings.
  • For all $i$ such that 1ドル \le i \le m,ドル string $t_i$ does not appear in $S$ as a substring.

입력

The first line contains one integer $T$ (1ドル\le T \le 10^5$) denoting the number of test cases. For each test case:

The first line contains two integers $n$ and $m$ (2ドル \le n \le 10^5,ドル 1ドル \le m \le 10^5$).

The following $n$ lines contain non-empty binary strings $s_1, s_2, \ldots, s_n,ドル one per line.

The following $m$ lines contain non-empty binary strings $t_1, t_2, \ldots, t_m,ドル one per line.

For the total sums over all test cases, it is guaranteed $\sum n + \sum m \le 10^5$ and that $\sum |s_i| + \sum |t_i| \le 10^6$.

출력

For each test case, output a line containing a single string: "Yes" (without quotes) if such a binary string $S$ exists, or "No" (without quotes) if not.

제한

예제 입력 1

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

예제 출력 1

Yes
No

힌트

For the first case, one possible string is "0100", where $s_1 = $100 and $s_3 = $010 appear in it, but $t_1 = $1001 and $t_2 = $000 don't appear.

출처

Camp > Petrozavodsk Programming Camp > Winter 2024 > Day 4: Peking U Contest 2 A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /