#K34887. Robot Path Existence
Robot Path Existence
Robot Path Existence
In this problem, you are given a 2D grid of size (n \times m) where each cell contains either 0 (an empty cell) or 1 (an obstacle). A robot starts at the top-left corner (cell (0,0)) and aims to reach the bottom-right corner (cell (n-1, m-1)). The robot is only allowed to move either down or right at any step. Your task is to determine whether there exists a valid path from the start to the destination.
Note: The grid indices are 0-based. A cell marked with 1 is considered blocked, and the robot cannot enter it. The starting cell and the destination cell must be accessible (i.e., they must be 0).
inputFormat
The input is read from standard input (stdin).
The first line contains two integers (n) and (m), representing the number of rows and columns of the grid, respectively.
Each of the next (n) lines contains (m) space-separated integers (each being 0 or 1), representing the grid.
outputFormat
Print a single line to standard output (stdout) containing the string "YES" if there exists a path from the top-left corner to the bottom-right corner by moving only down or right, otherwise print "NO".## sample
3 3
0 0 0
0 1 0
0 0 0
YES