#t346. 迷宫
迷宫
The Maze
Problem Background
Special for beginners, ^_^
Problem Description
One day, while exploring a forest, Extense accidentally wandered into a maze. The maze can be viewed as a grid of points, where each point has one of two states, . and #: the former means passable, the latter means blocked. When Extense is at a point, he can only move to an adjacent point in one of the four directions (up, down, left, or right). Extense wants to go from point A to point B. Determine whether this can be done without leaving the maze. If either the start or the end is blocked (i.e. #), it is considered impossible.
Input Format
The first line is the number of test cases , followed by groups of input. For each test case, the first line is a positive integer , the size of the maze (). Next is an matrix whose elements are . or #. Then one line contains four integers ha, la, hb, lb, describing that A is in row ha, column la, and B is in row hb, column lb. Note that ha, la, hb, lb are all 0-indexed.
Output Format
lines, one for each input. If it can be done, output YES; otherwise output NO.
Sample Input
2
3
.##
..#
#..
0 0 2 2
5
.....
###.#
..#..
###..
...#.
0 0 4 0
Sample Output
YES
NO
Constraints
1s, 1024KiB for each test case.