1181 : 矩阵字符串
时间限制Time Limit
1
秒Sec
内存限制Memory Limit
128
兆MB
提交次数Submitted
150 次Times
通过次数Solved
25 次Times
标准评测 Standard
从标准输入读入,结果写到标准输出。评测将输出拆成 token,与标准答案逐项比较,不按整段逐字节比对。
Read from standard input and write to standard output. The judge splits the output into tokens and compares them with the official answer; it does not compare raw bytes.
| 比对Compare | token 相同即通过。中间的空格、制表符、换行可多可少。Matching tokens pass. Extra spaces, tabs, or newlines between them are ignored. |
|---|---|
| 不同则错Differs | token 个数或内容不同即错误。23 与 2 3、02 与 2、2.0 与 2 均视为不同。A different token count or value is wrong. 23 vs 2 3, 02 vs 2, and 2.0 vs 2 all differ. |
| 输入Input | 标准输入,格式见题面。Standard input; format as in the statement. |
| 输出Output | 标准输出。Standard output. |
题目描述Description
在二维字符阵列中寻找指定的字符串。
字符串出现的形式可能是水平、竖直、向前、向后和斜向。输出的位置顺序应该与输入中的字符串出现顺序一致。区分字符的大小写。
如果某个字符串在字符阵列中出现多次,则输出描述起点、终点坐标四个数字依次最小的一个。
输入格式Input
多组测试数据,每组数据:
前两行分别指示字符矩阵的宽 w 和高 h( 1<=w<=80, 1<=h<=80)。
接下来的 h 行每行 w 个字符便是字符矩阵的内容,再下面的 1 行为要寻找的字符串的数目 n(n<10),其后的 n 行便是要寻找的字符串,每个字符串不会超过 20 个字符。
输出格式Output
n 行,每行输出对应字符串的位置。位置的格式形如(1,2)->(2,6),意为该字符串首字母在字符矩阵中的位置是第 1 列 2 行,尾字母在字符矩阵中的位置是第 2 列 6 行。