#K47742. Autonomous Vehicles Navigation
Autonomous Vehicles Navigation
Autonomous Vehicles Navigation
You are given a grid-based map representing a city divided into cells. Each cell is either free (denoted by '.') or blocked by an obstacle (denoted by '#'). For each test case, you are provided with the dimensions of the grid, the grid itself, and the starting and ending positions. Your task is to determine whether there is a valid path from the start to the destination by moving in four directions (up, down, left, right) without visiting blocked cells. Note that the positions are provided in 1-indexed format.
Formally, given a grid of size \( M \times N \) and start point \( (S_r, S_c) \) and end point \( (E_r, E_c) \), determine if there exists a path such that each move is to an adjacent cell and the cell contains a '.' character. Output YES
if a path exists, otherwise NO
.
inputFormat
The input is read from stdin and has the following format:
T M N row1 row2 ... (M rows in total) S_r S_c E_r E_c</p>(repeated T times)
Where:
T
is the number of test cases.M
andN
denote the number of rows and columns in the grid.- Each of the next M lines contains a string of length N consisting of '.' and '#' characters.
- The final line of each test case contains four integers: the starting row, starting column, ending row, and ending column (all 1-indexed). </p>
outputFormat
The output should be written to stdout. For each test case, output a single line containing either YES
if a valid path exists, or NO
otherwise.
1
3 4
....
..#.
....
1 1 3 4
YES