atcoder#ABC232D. [ABC232D] Weak Takahashi
[ABC232D] Weak Takahashi
Score : points
Problem Statement
There is a -square grid with horizontal rows and vertical columns. Let denote the square at the -th row from the top and -th column from the left.
Each square is described by a character , where .
means is an empty square, and #
means is a wall.
Takahashi is about to start walking in this grid. When he is on , he can go to or . However, he cannot exit the grid or enter a wall square. He will stop when there is no more square to go to.
When starting on , at most how many squares can Takahashi visit before he stops?
Constraints
- and are integers.
-
.
or#
. -
.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 4
.#..
..#.
..##
4
For example, by going $(1, 1) \rightarrow (2, 1) \rightarrow (2, 2) \rightarrow (3, 2)$, he can visit squares.
He cannot visit or more squares, so we should print .
1 1
.
1
5 5
.....
.....
.....
.....
.....
9