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

28308번 - CCC Word Hunt 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB87483457.627%

문제

In the CCC Word Hunt, words are hidden in a grid of letters. The letters of a hidden word always appear in order on horizontal, vertical, or diagonal line segments in one of two ways. One way is for the letters of a word to appear on one line segment. The other way is for the letters of a word to appear on one line segment up to some letter and then on a second line segment that forms a right angle at this letter.

Given a grid of letters and a single word to search for, your job is to determine the number of times that particular word is hidden in the grid.

입력

The first line of input will contain a string of distinct uppercase letters, $W,ドル representing the word you are to search for in the grid. The length of $W$ will be at least two.

The second line of input will be an integer $R$ $(1 \le R \le 100),ドル where $R$ is the number of rows in the grid.

The third line of input will be an integer $C$ $(1 \le C \le 100),ドル where $C$ is the number of columns in the grid.

The remaining input will provide the letters in the grid. It will consist of $R$ lines, where each line contains $C$ uppercase letters separated by single spaces.

출력

The output will consist of a single non-negative integer $H,ドル representing the number of times the word is hidden in the grid.

제한

예제 입력 1

MENU
5
7
F T R U B L K
P M N A X C U
A E R C N E O
M N E U A R M
M U N E M N S

예제 출력 1

3

The word MENU is hidden three times in the grid. Once horizontally, once vertically, and once diagonally as shown. Notice that a single letter can be used more than once.

예제 입력 2

NATURE
6
9
N A T S F E G Q N
S A I B M R H F A
C F T J C U C L T
K B H U P T A N U
D P R R R J D I R
I E E K M E G B E

예제 출력 2

4

The word NATURE is hidden four times in the grid. Once diagonally, once vertically, and twice on perpendicular line segments.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2023 > CCC 2023 Junior Division 5번

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

출처

대학교 대회

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

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