#K44292. Soccer Player Reachability
Soccer Player Reachability
Soccer Player Reachability
You are given a rectangular grid of size \( N \times M \) where each cell is either empty (denoted by '.') or contains an obstacle (denoted by '*'). A soccer player starts at a given cell and needs to reach the goal cell. The player can move up, down, left, or right (no diagonal moves) and cannot move into cells that contain obstacles.
Coordinates are 1-indexed. Determine if the player can reach the goal starting from the given position.
It is recommended to use a breadth-first search (BFS) algorithm to explore the grid.
inputFormat
The first line of input contains an integer \( T \) denoting the number of test cases. Each test case is described as follows:
- The first line contains two integers \( N \) and \( M \) — the number of rows and columns in the grid.
- The next \( N \) lines each contain a string of length \( M \) representing the grid. A dot ('.') represents an empty cell, and an asterisk ('*') represents an obstacle.
- The following line contains four integers: \( sx\), \( sy\), \( gx\), \( gy \) representing the starting and goal positions respectively. (All positions are 1-indexed.)
outputFormat
For each test case, output a single line containing YES
if the soccer player can reach the goal, or NO
if not.
2
3 4
....
.*..
....
1 1 3 4
3 3
..*
..*
...
1 1 2 3
YES
NO
</p>