#C3116. Taco Land: Largest Empty Plot

    ID: 46508 Type: Default 1000ms 256MiB

Taco Land: Largest Empty Plot

Taco Land: Largest Empty Plot

You are given a grid of dimensions \(n\) rows and \(m\) columns, where each cell of the grid is either an empty plot (represented by .) or an obstacle (represented by #). Your task is to compute the area of the largest rectangle that can be formed using only empty plots.

The problem can be modeled as follows: given a binary grid, find the maximum sub-rectangle consisting exclusively of empty cells. This is a classic computational geometry problem which can be efficiently solved using a histogram approach. In particular, consider each row as the bottom of a histogram and for every column maintain the count of consecutive empty plots from above. Then, using the algorithm for the largest rectangle in a histogram, you can compute the maximum area for each row.

Note: All formulas must be represented in LaTeX format. For example, the dimensions are given as \(1 \le n, m \le 1000\) and the area computed for any candidate rectangle is simply the product of its width and height.

inputFormat

The first line of input contains two integers (n) and (m) representing the number of rows and columns respectively. Each of the next (n) lines contains a string of length (m) consisting of characters '.' and '#' where '.' denotes an empty plot and '#' denotes an obstacle.

outputFormat

Output a single integer: the area of the largest rectangle that consists only of empty plots.## sample

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