All submissions for this problem are available.
The don of the Italian Mafia comes up with a list of names every five years, a rarity, when the books are open, a chance for some of the members of the crew to come up and be recognized by the mob. But due to the secretiveness of the organization the names are embedded in a matrix of letters so that it can’t be easily understood. After the boss gives this chit to one of his crew members to reveal it to the rest of the mob, he gets arrested and is now in custody with the CIA. So it’s now in the hands of the CIA to figure out the names to carry on their investigation.
Write a program to see if the names of the suspects the CIA has provided is in the matrix of letters given by the mob.
The first line of input contains the length (in characters) of the sides of the letter matrix (the matrix of letters will be square). The following x lines will be the letter matrix itself, each line will contain x uppercase letters. A list of words will follow after the matrix.
Each word will be on a line by itself containing only uppercase letters.
The final line of input will contain a single zero character.
Your program should search each word from the word list in the letter matrix. The search for word is successful if all the characters in the word can be searched in a sequence (unidirectional) either horizontal or diagonal or vertical line from the letter matrix. A word may be found from right to left (``backwards'') in horizontal and diagonal case. In case of successful search your program should print the coordinates of its first and last letter in the letter matrix on a single line, separated by a single space. Each set of coordinates should be 2 integers where the 1st integer denotes the row number and 2nd one points to the column number, both the integers are comma separated, where the index numbering begins from 1.
In case the search is unsuccessful the user should print “Not found''. The search will be successful only once.
- 1 ≤ x ≤ 100
Input: 5 ZDSSS DISKE ESJJJ ECEEE VVVVV DISC DISK DISP 0 Output: 1,2 4,2 2,1 2,4 Not found
Note : The reference for this problem has been taken from : UVa online Judge
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions