#C1075. Taco: Robot Grid Navigation

    ID: 39989 Type: Default 1000ms 256MiB

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:

  1. A line containing two integers n and m, representing the number of rows and columns of the grid.
  2. 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.

## sample
4 4
....
.##.
..#.
....
yes