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

7037번 - Walk the Talk 다국어

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

문제

Farmer John has set up a puzzle for his cows to solve. At the entrance to the barn, he has laid out an H x W (1 <= H <= 30, 1 <= W <= 30) grid of letters. Before a cow can enter the barn, she must spell out a valid English word by jumping from square to square, creating a sequence of letters. She can start at any square but may only jump to a subsequent square that is located to the right and/or above the current square (i.e., neither to the left nor lower). The next square can be any distance from the current one since the cows are world-class jumpers!

No two cows may traverse the exact same path, although two cows are allowed to spell the same word via different paths.

As an example, consider this grid (presuming 'TO' and 'OX' are words):

T X X O
T X Q T
X T X Q

Four paths are valid, all spelling 'TO' (one spelling requires a 'T' from the bottom row and an 'O' from the top row). 'OX' is a valid word, but would require jumping to an 'X' square left of the 'O', which is not allowed.

Given the grid and a list of valid words, compute the number of cows that can enter the barn without any cow repeating a path. See a copy of the list here.

입력

  • Line 1: Two integers: H and W
  • Lines 2..H+1: Each line contains W characters, without spaces, representing a row in the grid. The first row is the top row.The first character in each row is the left-most character.

출력

  • Line 1: The number of cows that can enter the barn without repeating a path.

제한

예제 입력 1

3 4
TXXO
TXQT
XTXQ

예제 출력 1

4

힌트

출처

Olympiad > USA Computing Olympiad > 2005-2006 Season > USACO November 2005 Contest > Gold 3번

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

출처

대학교 대회

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

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