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
flower: 2023-09-16 13:01:28

Very instructive problem, however thumbs down for (presumably) the problem setter redacting all helpful hints from the comments, but not the asinine and annoying "AC in one go".

divyansh2212: 2021-12-11 13:35:48

That green color! XD

vee_nits123: 2020-09-21 15:56:01

Graph[r][c] == alliswell[ptr]
alliswell="ALLIZZWELL"
the whole hint ;)

aquib_ansari: 2019-09-10 08:45:45

Used [spoiler], but repeatedly failing on tc 2 ? what am i not testing for ?

Last edit: 2019-11-04 16:24:32
sachin_0: 2019-03-08 21:58:52

NOTE :
multiple 'A' is also there like...
1
3 10
LLEIZZWEAL
ALLIZZWELA
IZZWELAAAA

Ans: YES

zarif_2002: 2019-02-26 11:56:07

aaa.......ll iss wellllll........

rajan3597: 2018-09-01 19:35:11

for those getting WA in 2nd case
check [spoiler]

Last edit: 2019-01-05 12:32:28
maya_nk99: 2018-08-30 20:02:15

what is the second test case??

karan_yadav: 2018-07-15 20:06:28

DId it using [spoiler]
Though if you think about it, [spoiler] in itself is very similar to [spoiler]

Last edit: 2018-08-22 16:01:39
spaceman_spiff: 2018-07-02 19:32:07

Is it right to assume that there will be R*C characters in the description of the matrix?
i.e. are test cases of the form
1
3 5
ALLIZ
LLEWZ
<no characters for third line>
<end of test case>

correct ??

EDIT: Test cases of the form are not there. Phew.

Last edit: 2018-07-04 18:15:09

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