Submit | All submissions | Best solutions | Back to list |
ALLIZWEL - ALL IZZ WELL |
Mr.ESP used to tell “ALL IZZ WELL” whenever he gets into any trouble. So his friends and the people around him used to laugh at him. But Mr.ESP is very strong in his belief. He believes that the term “ALL IZZ WELL” will make everything fine. Now your task is to ignore the story above and find whether there is a path in the given matrix which makes the sentence “ALL IZZ WELL”
There is a path from any cell to all its neighbouring cells. A neighbour may share an edge or a corner.
Input Specification:
The first line consists of an integer t representing the number of test cases.
The first line of each test case consists of two integers R and C representing the number of rows and number of columns in the matrix. The description of the matrix follows.
Output Specification:
For each test case print “YES” if there is a path which makes the sentence “ALLIZZWELL”. Else print “NO”.
Note: Take care of 4th test case
There is a new line after every test case in the input.
Input constraints:
t <= 1000
R <= 100
C <= 100
Sample Input:
5 3 6 AWE.QX LLL.EO IZZWLL 1 10 ALLIZZWELL 2 9 A.L.Z.E.. .L.I.W.L. 3 3 AEL LWZ LIZ 1 10 LLEWZZILLASample Output:
YES YES NO NO YES
Added by: | cegprakash |
Date: | 2011-12-25 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
hide comments
|
||||||||||||
2015-06-22 09:19:25 yvn
@Rohit Gupta when you are backtracking do make the cell unvisited |
||||||||||||
2015-06-18 20:26:26 Raghav Aggiwal Again
Yeah maroof , same here ! |
||||||||||||
2015-06-18 18:49:39 Maroof
easy with recursive dfs. But its difficult to code when i use iterative dfs(stack) |
||||||||||||
2015-05-19 13:34:49 Tim Wargon
Test Case provided by @Karan2K was helpful: 1 3 4 AEW. LLIZ LL.Z Output should be YES. |
||||||||||||
2015-04-20 19:15:10 Priyanjit Dey
try out this testcase: 1 4 5 ALL.. ..... ALLIZ LLEWZ OUTPUT:YES. |
||||||||||||
2015-03-12 11:34:06 kelaseek
nice |
||||||||||||
2015-02-08 07:49:36 dhumketu
1 3 3 AEL LWZ LIZ Shouldn't the answer be yes? |
||||||||||||
2015-01-23 04:49:33 Kanish
NICE QUESTION :-) |
||||||||||||
2015-01-17 21:09:22 krish
recursive dfs.. ALLZ .IZW .LLE output should be YES. |
||||||||||||
2015-01-16 12:00:41 Harsh Rumalwala
Got 1 WA as didn't reuse the values.. Test Case of @KaranVerma was very helpful... |