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

17908번 - Hidden Words 다국어

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

문제

Ingrid is solving the Saturday newspaper Hidden Words in a Grid puzzle, but is finding it a bit tedious to do by hand. Luckily Ingrid knows how to program, and has written a neat image recognition routine that converts a picture of the puzzle into a nice text-based format. However, she is struggling with writing the program that actually solves the puzzle – can you help her out?

A word is contained within a h by w grid if the word can be constructed by starting in a cell in the grid and walking from there to neighboring unvisited cells. A cell neighbors another cell if it is adjacent, not including diagonal movement. Given such a grid and a list of words, decide how many of the words in the list are contained in the grid.

입력

The first line consists of two integers h and w (1 ≤ h, w ≤ 10), the height and width of the grid. Then h lines follow, each containing a string of length w consisting exclusively of uppercase letters describing one row of the grid. Then follows a line with a single integer n (1 ≤ n ≤ 100 000), indicating the number of words Ingrid is looking for. Finally the n words follow, each on a separate line. None of these words are longer than 10 characters.

출력

The output consists of a single number, the number of words underneath the grid that are contained in the grid.

제한

예제 입력 1

4 4
SNKO
VRER
IDIN
NEGU
3
KORN
NEDI
DER

예제 출력 1

2

힌트

출처

Contest > Bergen Open > Bergen Open 2018 H번

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

출처

대학교 대회

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

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