#K301. Path Finding in a Grid
Path Finding in a Grid
Path Finding in a Grid
You are given a grid of size , where each cell is either free (0) or blocked (1). The goal is to determine if there exists a path from the top-left cell to the bottom-right cell by moving only right or down. Note that the starting and destination cells must be free. If a valid path exists, print "YES"; otherwise, print "NO".
inputFormat
The input is read from standard input. The first line contains two integers and , representing the number of rows and columns respectively. Each of the following lines contains space-separated integers (0 or 1) indicating the state of each cell in the grid.
outputFormat
Output a single line to standard output containing either "YES" if there exists a path from the top-left to the bottom-right corner, or "NO" otherwise.## sample
3 3
0 1 0
0 0 0
1 1 0
YES