#d2801. 走不出的迷宫
走不出的迷宫
The Inescapable Maze
Problem Description
There is a maze of rows and columns (rows are numbered to from top to bottom, columns to from left to right). The maze is given as an matrix of . and #, where . is open ground you can pass through and # is a wall you cannot cross.
A person starts at and at each step may move only one cell to the right or one cell down, without leaving the maze. He keeps walking until there is no legal move left, then stops.
What is the maximum number of cells he can pass through?
Input Format
The first line contains two integers and : the maze has rows and columns.
Then follows an matrix of . and # describing the maze.
Note: is guaranteed to be ..
Output Format
Output one integer: the maximum number of cells that can be visited.
Sample Input 1
3 4
.#..
..#.
..##
Sample Output 1
4
Sample Input 2
1 1
.
Sample Output 2
1
Sample Input 3
5 5
.....
.....
.....
.....
.....
Sample Output 3
9
Constraints
.