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
LLEWZZILLA
Sample Output:
YES
YES
NO
NO
YES

hide comments
innovolt: 2014-08-16 19:28:09

mast use of backtracking....

Master_Mind: 2014-06-20 20:17:33

taking each row as string worked!!

DEVANSH PARASHAR: 2013-12-21 22:32:28

wrong ans plz any tricky test case
finally AC

Last edit: 2013-12-23 19:23:17
Martijn Muijsers: 2013-11-01 00:31:16

Important: the path cannot cross the same coordinate twice!
Couldn't find that in the description, but it's true due to test case 4.

Vipul Pandey: 2013-09-12 18:46:53

nice one! Just require the knowledge of recursion.

Gaurav Mishra: 2013-08-23 09:45:58

<snip> WA please help, exploited every test cases still :(

Last edit: 2022-07-20 19:46:01
Bruce: 2013-08-12 14:26:22

i dont understand why i am getting WA?
is there any twist in getting i/p??

Ouditchya Sinha: 2013-07-17 14:30:53

Nice problem! :)

BLANKRK: 2013-07-01 16:03:44

finally over...

Hariharan: 2013-06-27 13:42:08

can anyone clarify what a neighbouring cell means? are the neighbours cells the eight cells surounding a given interior cell?

suppose if i am at (i,j)
the neighbouring cells are
i,j+1
i,j-1
i+1,j
i-1,j
i+1,j+1
i-1,j-1
i-1,j+1
i+1,j-1
only?

if these are the only cells that are called neighbouring, is there any other reason for WA except for wrong traversal? like maybe suggest such a test case,

I keep getting WA. please check 9561888

Last edit: 2013-06-28 12:11:49

Added by:cegprakash
Date:2011-12-25
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64