#B3625. Doraemon in the Maze
Doraemon in the Maze
Doraemon in the Maze
Doraemon is trapped in a rectangular maze represented as an grid. Each cell in the maze is either an empty space or a wall. Doraemon can only move from one empty cell to an adjacent empty cell in the four cardinal directions: up, down, left, and right.
The starting position is at the top-left corner, i.e. cell , and the goal is to reach the bottom-right corner, i.e. cell .
Determine whether Doraemon can reach the destination. If he can, print YES
; otherwise, print NO
.
The maze cells are given as follows: a '.' (dot) represents an empty space, and a '#' (hash) represents a wall.
inputFormat
The first line contains two integers and , representing the number of rows and columns of the maze respectively.
Each of the following lines contains a string of length consisting of characters '.' and '#' that describe the maze.
outputFormat
Output a single line containing YES
if Doraemon can go from cell to cell through empty cells only, or NO
otherwise.
sample
3 3
...
.#.
...
YES