Question to Life, Universe and Everything
Long ago on planet Xartha there lived a wise man, Lavit. He found the Ultimate question to Life, Universe
and everything. But then there was captain Xoxo who wanted this supreme knowledge. To thwart the evil
plans of Xoxo, Lavit encoded the Ultimate question into a magical matrix.
The magical matrix was a M X N matrix of characters where words can be formed by moving horizontally
or vertically, and using each character at most once. When Captain Xoxo hears this news from a spy, he
wages a war against Lavit. Lavit manages to keep the matrix to himself, but he forgets the ultimate
question. Still he has his hands on a list of questions and he is sure the question was one from this list.
Now since finding all the words in the matrix is too tedious a task, Lavit needs you to find the question for him.
You will be given access to the special matrix, and Lavit will give you his list of questions. You will need
to tell Lavit the Ultimate question. You need to ignore character case while comparing.
The first line will contain two Integers, M and N.
The next M lines will contain a string of N characters each.
Next Line will contain an Integer L denoting number of questions in Lavit's list.
Each of the next L lines will contain a question.
Output a single line, The ultimate question to Life, Universe and everything.
- 1 ≤ M, N ≤ 6
- 1 ≤ L ≤ 100
- 1 ≤ Length of each question in List ≤ 6*M*N
Input: 3 3 has pps ine 5 food luxury money happiness happening Output: happiness
The only word from the list that can be found in the matrix is happiness
|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