Help Briliano !!!
Time Limit: 3 sec
The Problem
Briliano is a programmer. He loves to solve problems and always try to solve ONE PROBLEM IN A DAY. Like every day he opened up a problem today and tried his best to solve. But failed! So he is asking your help.
Ah! It’s a board game problem. In this game you will have a M X N board of 0 and 1s where M is the number of rows and N is the number of columns. The game will start from a starting point (S) and have to reach the ending point (E) through connected 1s. Assume starting and ending point will be 1. Points can connect to its adjacent diagonally or horizontally if it’s 1.
The Input
The first line of input will be the no of test cases T then T test cases follow (0<T<100). The first line of each test case contains Two space separated integers M and N (0<M, N<50). Then in the next M lines contains N space separated integers, 0 or 1. And at the last line of each test case contains Four space separated integers (Sx, Sy, Ex, Ey) which are the location of starting point (S) and ending point (E) (0<Sx, Ex <=M and 0<Sy, Ey<=N).
The Output
For each test case print YES in a new line if you can reach the end point other wise print NO
Sample Input
2
6 6
0 0 0 0 0 1
0 1 0 0 0 1
0 1 0 0 1 0
0 0 1 0 1 0
1 0 1 1 0 0
1 0 0 0 0 1
2 2 1 6
6 6
1 1 0 1 0 1
0 0 0 1 1 1
0 1 0 0 0 0
0 1 0 1 1 0
0 1 0 0 0 0
0 0 0 1 1 1
3 2 4 4
Sample Output
YES
NO
[School & College Level]
Inter School & College Programming Contest (ISCPC) 2017
Problem Setter: Md. Helal Uddin