#K76852. Largest Empty Rectangle in a Garden
Largest Empty Rectangle in a Garden
Largest Empty Rectangle in a Garden
You are given a rectangular garden represented as a grid of characters. Each cell in the garden is either empty ('.') or occupied by a flower ('*'). Your task is to determine the area of the largest rectangular region that contains only empty cells.
The rectangle must be aligned with the grid. In other words, its sides are parallel to the rows and columns of the garden.
Mathematical Formulation:
Let \( G \) be an \( n \times m \) grid where \( G_{i,j} \in \{'.', '*'\} \). Find the maximum area \( A = h \times w \) such that there exists a submatrix of size \( h \times w \) where every cell is '.'
Example: For a one-row garden "....", the largest empty rectangle has an area of 4.
inputFormat
The input is read from standard input (stdin). The first line contains a single integer ( n ) representing the number of rows in the garden grid. Each of the next ( n ) lines contains a non-empty string of equal length representing a row of the garden. The characters in the string are either '.' (denoting an empty cell) or '*' (denoting a flower).
outputFormat
Output to standard output (stdout) a single integer representing the area of the largest rectangular region composed entirely of empty cells.## sample
1
....
4