#C2568. Taco Grid Navigation

    ID: 45898 Type: Default 1000ms 256MiB

Taco Grid Navigation

Taco Grid Navigation

Problem Description

You are given a grid of size \(N \times M\) where each cell is either open or blocked. The open cells are represented by a period ('.') and the blocked cells by a hash ('#'). Your task is to determine whether it is possible to traverse from the top-left cell (cell \(1,1\)) to the bottom-right cell (cell \(N,M\)) by only moving either right or down, without stepping on a blocked cell.

Note: The grid is 1-indexed, and you cannot move outside of it.

inputFormat

The first line contains two integers (N) and (M) separated by a space, representing the number of rows and columns respectively. The following (N) lines each contain a string of length (M), representing the grid. Each character in the string is either '.' (an open cell) or '#' (a blocked cell).

outputFormat

Output a single line containing "YES" if there exists a valid path from the top-left cell to the bottom-right cell; otherwise, output "NO".## sample

3 3
...
...
...
YES

</p>