시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB27151565.217%

문제

Find parts of a 2d grid matching a 2d word.

입력

  • One line containing the number of rows and columns in the search key, $r_k$ and $c_k$ ($1 \le r, c \le 2000$).
  • $r_k$ further lines, each containing $c_k$ Latin characters comprising a row of the search key.
  • One line containing the number of rows and columns in the haystack, $r_h$ and $c_h$ ($r_k \le r_h \le 2000$, $c_k \le c_h \le 2000$).
  • $r_h$ further lines, each containing $c_h$ Latin characters comprising a row of the search key.

출력

Illustrate the matching areas of the haystack by printing a grid of the same size. In locations that are part of at least one match, print the original character from the haystack. In other cases, print a full-stop "." character.

예제 입력 1

3 3
ghi
lmn
qrs
5 5
abcde
fghij
klmno
pqrst
uvwxy

예제 출력 1

.....
.ghi.
.lmn.
.qrs.
.....

예제 입력 2

1 2
ab
6 4
abba
baab
abba
baab
abba
baab

예제 출력 2

ab..
..ab
ab..
..ab
ab..
..ab

예제 입력 3

4 1
n
a
n
a
7 6
ananan
nanana
ananan
nanana
ananan
nanana
batman

예제 출력 3

.n.n.n
nanana
ananan
nanana
ananan
.a.ana
....a.

예제 입력 4

2 2
oo
oo
5 5
xoooo
oxooo
ooxoo
oooxo
oooox

예제 출력 4

..ooo
..ooo
oo.oo
ooo..
ooo..

출처

ICPC > Regionals > Europe > Northwestern European Regional Contest > The UK & Ireland Programming Contest > UKIEPC 2024 G번

  • 문제를 만든 사람: Robin Lee