当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3043:Walk the Talk

题目描述
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 H+2: A blank line

* Line H+3..: The list of valid words
输出解释
* Line 1: The number of cows that can enter the barn without repeating a path.
输入样例
3 4
TXXO
TXQT
XTXQ

A
AA
AAA
...
输出样例
4
提示
OUTPUT DETAILS:
4 cows can enter the barn, each one spelling out one of the 'TO's.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3043

最后修改于 2020-10-29T06:51:04+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536