#C9067. Taco - Path to the End
Taco - Path to the End
Taco - Path to the End
You are given a grid of size ( n \times m ) where each cell is represented by a character. The grid contains three types of cells:
- '.' : a safe cell you can step on
- '#' : a wall (obstacle)
- 'T' : a trap cell that you must avoid
Your task is to determine if there exists a path from the top-left cell (0,0) to the bottom-right cell (n-1, m-1) that only goes through safe cells ('.'). Movement is allowed in four directions: up, down, left, and right.
Input/Output:
- Input: The first line contains two integers, n and m. The next n lines each contain a string of length m representing the grid.
- Output: Print "Yes" if such a path exists, otherwise print "No".
Note: All formulas are represented in LaTeX format, e.g., ( n \times m ) denotes the grid dimensions.
inputFormat
The first line contains two space-separated integers ( n ) and ( m ) representing the number of rows and columns respectively. This is followed by ( n ) lines, each containing a string of length ( m ) consisting of the characters '.', '#', and 'T', which represent a safe cell, a wall, and a trap respectively.
outputFormat
Output a single line containing either "Yes" or "No" (without quotes). "Yes" indicates that there is a valid path from the top-left cell to the bottom-right cell using only safe cells, while "No" indicates that no such path exists.## sample
1 1
.
Yes
</p>