#C9365. Path to the End
Path to the End
Path to the End
You are given a square grid of size \(n \times n\). Each cell of the grid is either free (denoted by .
) or blocked (denoted by #
). You start at the top-left cell (cell \( (0, 0) \)) and your goal is to reach the bottom-right cell (cell \( (n-1, n-1) \)).
You can only move in two directions: right or down. Determine whether there exists a path from the start to the goal while only moving right or down.
Note: The starting cell and the destination cell must be free. If either is blocked, the answer is False
.
inputFormat
The input is given via standard input. The first line contains an integer \(n\) representing the size of the grid. This is followed by \(n\) lines, each containing a string of length \(n\) consisting only of characters '.' (free cell) and '#' (blocked cell).
outputFormat
Output a single line to standard output: True
if there is a valid path from the top-left cell to the bottom-right cell following the allowed moves, otherwise False
.
4
....
..#.
.#..
....
True