#K59492. Taco Path Problem

    ID: 30876 Type: Default 1000ms 256MiB

Taco Path Problem

Taco Path Problem

You are given a 2D grid of size n × m composed of characters '.' and '#', which represent empty and blocked cells respectively. A robot starts at the top-left corner (position (0,0)) and its goal is to reach the bottom-right corner (position (n−1, m−1)). The robot can move in four directions: up, down, left, and right.

Your task is to determine whether the robot can reach the destination with a path that is at most threshold in length. Formally, if there exists a path from the start to the destination with length \(L\) such that \(L \leq \text{threshold}\), output "Yes", otherwise output "No".

Note: The starting cell or destination cell may be blocked. In such cases, the answer is "No".

Input Format Example:

4 4 6
..#.
#.#.
...#
##..

Output:

Yes

inputFormat

The first line contains three integers n, m, and threshold (1 ≤ n, m ≤ 1000, threshold ≥ 0), where n and m denote the number of rows and columns of the grid respectively.

The following n lines each contain a string of length m consisting of characters '.' and '#' without spaces, representing the grid.

outputFormat

Output a single line containing either Yes or No (without quotes). If the robot can reach the destination within the given threshold, output Yes; otherwise, output No.

## sample
4 4 6
..#.
#.#.
...#
##..
Yes