#C1075. Taco: Robot Grid Navigation
Taco: Robot Grid Navigation
Taco: Robot Grid Navigation
A robot is placed at the top-left corner of a 2D grid and its goal is to reach the bottom-right corner. The grid consists of free cells (denoted by .
) and obstacles (denoted by #
). The robot can only move to the right or down at each step.
Your task is to determine whether there exists a valid path from the starting point to the destination. Note that the robot cannot pass through obstacles and cannot move outside the grid boundaries.
Constraints:
- The first cell (top-left) and the last cell (bottom-right) must be free; otherwise, the answer is immediately "no".
- The robot only moves in two directions: right and down.
The answer should be yes
if a valid path exists and no
if it does not.
inputFormat
The input is given from standard input (stdin) and consists of:
- A line containing two integers n and m, representing the number of rows and columns of the grid.
- n subsequent lines, each containing a string of length m, representing the grid rows. Each character is either
.
(free cell) or#
(obstacle).
outputFormat
Output a single line to standard output (stdout) containing either yes
if a valid path exists, or no
otherwise.
4 4
....
.##.
..#.
....
yes