#C2940. Path Existence in a Grid
Path Existence in a Grid
Path Existence in a Grid
Given an grid where each cell contains either 0 (an empty cell) or 1 (an obstacle), determine whether there exists a path from the top-left corner to the bottom-right corner . You may move in the four cardinal directions (up, down, left, right), but you cannot move through obstacles. All moves must remain within the bounds of the grid.
inputFormat
The input is read from stdin. The first line contains two integers and , representing the number of rows and columns respectively. Each of the following lines contains integers (either 0 or 1) separated by spaces, representing the grid.
outputFormat
Print to stdout a single line: "True" if there is a valid path from the top-left to the bottom-right, or "False" otherwise.## sample
3 3
0 0 1
0 1 0
0 0 0
True