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

建议使用的浏览器:

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

1857:Word Puzzle

题目描述
Did you heard of a little game named "Word Puzzle" ? If you didn't, what a pity !
In the game, you will be given a rectangular grid of letters, in which several words are hidden. Each word may begin anywhere in the puzzle, and may be oriented in any straight line horizontally, vertically, or diagonally. However, the words must all go down, right, or down-right. A dictionary is also given to you, indicating the words to be found in the grid.

You task is to find the locations of each word within the grid.

输入解释
There is only one test case.

The first line is two integers R and C separated by a whitespace. R (20 ≤ R ≤ 500) is the number of rows of the grid. C (20 ≤ C ≤ 500) is the number of columns of the grid.

The following R lines, each line will contains exactly C characters without anything else. Each character is in the range 'A' - 'Z'.

A blank line will be followed after the grid.

The following lines, each line contains a unique word in the dictionary. Each word will contain between 1 and 20 characters ( also in the range 'A' - 'Z'). The dictionary consists of at most 10000 words.

-1 means the end of dictionary.

输出解释
For each word, output the "ROW COL"(quotes for clarity) pair, where ROW is the 0-based row in which the first letter of the word is found, and COL is the 0-based column in which the first letter of the word is found. If the same word can be found more than once, the location in the lowest-indexed row should be returned. If there is still a tie, return the location with the lowest-indexed column. If a word cannot be found in the grid, return "-1 -1" for the word.
输入样例
3 5
HENRY
GAVIN
MAGIC

HENRY
HGM
HAG
MAVIN
-1
输出样例
0 0
0 0
0 0
-1 -1
来自杭电HDUOJ的附加信息
Author XrtGavin@TJU
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-1857

最后修改于 2020-10-25T22:48:20+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000/1000MS(Java/Others) 65536/32768K(Java/Others)