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

6935번 - Post's Correspondence Problem 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB86675.000%

문제

Let $A$ and $B$ be two sequences of non-empty strings:

$$\displaystyle \begin{align*} A &= (a_1, a_2, \dots, a_n) \\ B &= (b_1, b_2, \dots, b_n) \end{align*}$$

Let $m$ be a positive integer. Does there exist a sequence of integers $i_1, i_2, \dots, i_k$ such that $m > k > 0$ and $a_{i_1} a_{i_2} \dots a_{i_k} = b_{i_1} b_{i_2} \dots b_{i_k}$?

For example, if $A = (a, abaaa, ab)$ and $B = (aaa, ab, b),ドル then the required sequence of integers is $(2, 1, 1, 3)$ giving $abaaaaaab = abaaaaaab$.

입력

The first two lines of input will contain $m$ and $n$ respectively, and $m \times n \le 40$. The next 2ドルn$ lines contain in order the elements of $A$ followed by the elements of $B$. Each string is at most 20ドル$ characters.

출력

If a solution exists, print $k$ on a line by itself, followed by the integer sequence in order, one element per line. Otherwise, print a single line containing No solution..

제한

예제 입력 1

7
3
a
abaaa
ab
aaa
ab
b

예제 출력 1

4
2
1
1
3

예제 입력 2

10
3
abc
def
ghi
bcd
efg
hia

예제 출력 2

No solution.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2001 > CCC 2001 Senior Division 5번

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

출처

대학교 대회

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

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