#K66242. Robot Maze: Reach the Bottom-Right Cell

    ID: 32377 Type: Default 1000ms 256MiB

Robot Maze: Reach the Bottom-Right Cell

Robot Maze: Reach the Bottom-Right Cell

Given a grid of size (m \times n), where each cell is either 0 (free) or 1 (blocked), determine if a robot starting at the top-left corner (0,0) can reach the bottom-right corner ((m-1, n-1)). The robot can move one step at a time in four directions: up, down, left, and right. It may only move to cells containing 0. Return True if there exists a path from the start to the goal; otherwise, return False.

inputFormat

The input is given via standard input (stdin). The first line contains two space-separated integers (m) and (n) representing the number of rows and columns of the grid, respectively. This is followed by (m) lines, each containing (n) space-separated integers (each either 0 or 1) representing the grid.

outputFormat

Output via standard output (stdout) a single line containing either “True” if the robot can reach the bottom-right cell, or “False” otherwise.## sample

3 3
0 0 0
0 1 0
0 0 0
True