WPUZZLES - Word Puzzles

题意翻译

-------- ### 题目描述: 给出一个由大写字母组成的L*C的图案,给出W个询问,每个询问给出一个字符串,输出该字符串在图案中出现的位置(保证询问的字符串都可以在图案中找到,若有多个解,输出其中一个解即可) ------------ ### 输入格式: 给出T组数据,对于每组数据: 第1行包含3个整数,L,C,W(0<L,C,W<=1000),分别为行数、列数和询问数量. 第2~L+1行,每行C个字符给出图案 第L+2~L+W+1行,每行一个任意长度的字符,表示要求你在图案中找出该字符串 ### 输出格式: 对于每组数据,输出W行,每行2个数字及一个字符,分别表示该询问的字符串在图案中出现的位置(第一个字母的坐标,从0开始)及该字符串的方向,向上为记A,字母沿方向顺时针递增,共有8种方向。 ##### 在每组数据之间输出一个换行

题目描述

Word puzzles are usually simple and very entertaining for all ages. They are so entertaining that Pizza-Hut company started using table covers with word puzzles printed on them, possibly with the intent to minimise their client's perception of any possible delay in bringing them their order. Even though word puzzles may be entertaining to solve by hand, they may become boring when they get very large. Computers do not yet get bored in solving tasks, therefore we thought you could devise a program to speedup (hopefully!) solution finding in such puzzles. The following figure illustrates the PizzaHut puzzle. The names of the pizzas to be found in the puzzle are: MARGARITA, ALEMA, BARBECUE, TROPICAL, SUPREMA, LOUISIANA, CHEESEHAM, EUROPA, HAVAIANA, CAMPONESA. 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 0 Q W S P I L A A T I R A G R A M Y K E I 1 A G T R C L Q A X L P O I J L F V B U Q 2 T Q T K A Z X V M R W A L E M A P K C W 3 L I E A C N K A Z X K P O T P I Z C E O 4 F G K L S T C B T R O P I C A L B L B C 5 J E W H J E E W S M L P O E K O R O R A 6 L U P Q W R N J O A A G J K M U S J A E 7 K R Q E I O L O A O Q P R T V I L C B Z 8 Q O P U C A J S P P O U T M T S L P S F 9 L P O U Y T R F G M M L K I U I S X S W 10 W A H C P O I Y T G A K L M N A H B V A 11 E I A K H P L B G S M C L O G N G J M L 12 L D T I K E N V C S W Q A Z U A O E A L 13 H O P L P G E J K M N U T I I O R M N C 14 L O I U F T G S Q A C A X M O P B E I O 15 Q O A S D H O P E P N B U Y U Y O B X B 16 I O N I A E L O J H S W A S M O U T R K 17 H P O I Y T J P L N A Q W D R I B I T G 18 L P O I N U Y M R T E M P T M L M N B O 19 P A F C O P L H A V A I A N A L B P F S

输入输出格式

输入格式


The first line of the input contains a number T ≤ 10 which indicates the number of test cases to follow. Each test case starts with a line consisting of three positive numbers: The number of lines of the word puzzle, 0 < L ≤ 1000, the number of columns, 0 < C ≤ 1000, and the number of words to be found, 0 < W ≤ 1000. The following L input lines, each consisting of C uppercase letters, contain the word puzzle. Then at last the W words are input one per line. You can assume that each word can be found exactly once in the word puzzle.

输出格式


For each test case your program should output W lines: For each word (using the same order as the words were input) print a triplet defining the coordinates, line and column, where the first letter of the word appears, followed by a letter indicating the orientation of the word according to the rules defined above. Each value in the triplet must be separated by one space only. **Print one blank line between test cases.**

输入输出样例

输入样例 #1

1
20 20 10
QWSPILAATIRAGRAMYKEI
AGTRCLQAXLPOIJLFVBUQ
TQTKAZXVMRWALEMAPKCW
LIEACNKAZXKPOTPIZCEO
FGKLSTCBTROPICALBLBC
JEWHJEEWSMLPOEKORORA
LUPQWRNJOAAGJKMUSJAE
KRQEIOLOAOQPRTVILCBZ
QOPUCAJSPPOUTMTSLPSF
LPOUYTRFGMMLKIUISXSW
WAHCPOIYTGAKLMNAHBVA
EIAKHPLBGSMCLOGNGJML
LDTIKENVCSWQAZUAOEAL
HOPLPGEJKMNUTIIORMNC
LOIUFTGSQACAXMOPBEIO
QOASDHOPEPNBUYUYOBXB
IONIAELOJHSWASMOUTRK
HPOIYTJPLNAQWDRIBITG
LPOINUYMRTEMPTMLMNBO
PAFCOPLHAVAIANALBPFS
MARGARITA
ALEMA
BARBECUE
TROPICAL
SUPREMA
LOUISIANA
CHEESEHAM
EUROPA
HAVAIANA
CAMPONESA

输出样例 #1

0 15 G
2 11 C
7 18 A
4 8 C
16 13 B
4 15 E
10 3 D
5 1 E
19 7 C
11 11 H