| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 896 人关注过本帖
标题:Where's Waldorf?提问
只看楼主 加入收藏
栖库稀
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-10-13
收藏
 问题点数:0 回复次数:3 
Where's Waldorf?提问
Background
Given an m by n grid of letters and a list of words, find the location in the grid at which the word can be found.

A word matches a straight, uninterrupted line of letters in the grid. A word can match the letters in the grid regardless of case (i.e., upper- and lowercase letters are to be treated as the same). The matching can be done in any of the eight horizontal, vertical, or diagonal directions through the grid.

Input
The input begins with a single positive integer on a line by itself indicating the number of cases, followed by a blank line. There is also a blank line between each two consecutive cases.

Each case begins with a pair of integers m followed by n on a single line, where 1 ≤ m, n ≤ 50 in decimal notation. The next m lines contain n letters each, representing the grid of letters where the words must be found. The letters in the grid may be in upper- or lowercase. Following the grid of letters, another integer k appears on a line by itself (1 ≤ k ≤ 20). The next k lines of input contain the list of words to search for, one word per line. These words may contain upper- and lowercase letters only – no spaces, hyphens, or other non-alphabetic characters.

Output
For each word in each test case, output a pair of integers representing its location in the corresponding grid. The integers must be separated by a single space. The first integer is the line in the grid where the first letter of the given word can be found (1 represents the topmost line in the grid, and m represents the bottommost line). The second integer is the column in the grid where the first letter of the given word can be found (1 represents the leftmost column in the grid, and n represents the rightmost column in the grid). If a word can be found more than once in the grid, then output the location of the uppermost occurrence of the word (i.e., the occurrence which places the first letter of the word closest to the top of the grid). If two or more words are uppermost, output the leftmost of these occurrences. All words can be found at least once in the grid.

The output of two consecutive cases must be separated by a blank line.

[[it] 本帖最后由 栖库稀 于 2008-10-15 21:59 编辑 [/it]]
搜索更多相关主题的帖子: Waldorf Where 提问 
2008-10-13 22:12
栖库稀
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-10-13
收藏
得分:0 
没人理。。。。。。
2008-10-14 14:00
静夜思
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:济南的冬天
等 级:管理员
威 望:11
帖 子:8917
专家分:2567
注 册:2004-3-25
收藏
得分:0 
把“跪求”两个字去掉吧,凭个人感觉,看见这两个字就不想点开这个帖子了

畅所欲言
2008-10-14 14:14
栖库稀
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-10-13
收藏
得分:0 
依然没人理。。。。。
2008-10-15 22:00
快速回复:Where's Waldorf?提问
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016587 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved