#P3135. Fort Construction

    ID: 16393 Type: Default 1000ms 256MiB

Fort Construction

Fort Construction

Bessie and her friend Elsie wish to build a fort on a plot of land. They plan to start with a sturdy frame – a one‐meter wide rectangular outline – upon which the fort will be established. The plot of land is a grid of size N by M (in meters) and contains some swampy areas that cannot support the frame. The frame of the fort must have its entire border (i.e. the top row, bottom row, left column, and right column of the chosen rectangle) on non‐swampy ground (denoted by a period .). The interior of the fort (the area enclosed by the frame) is given by

Area=(r2r11)×(c2c11)Area = (r_2 - r_1 - 1) \times (c_2 - c_1 - 1)

where r1 and r2 are the indices of the top and bottom rows of the rectangle and c1 and c2 are the indices of the leftmost and rightmost columns. Note that a valid frame must have at least three rows and three columns so that there is an interior region. If no valid rectangle exists, output 0.

Input Specification: The first line contains two integers N and M (1 ≤ N, M ≤ 200). The following N lines each contain a string of length M composed of the characters . (suitable ground) and # (swampy area).

Output Specification: Output a single integer, the maximum area of the interior fort that can be supported by a one‑meter wide rectangular frame whose border does not cover any swampy area.

inputFormat

The input begins with two integers N and M. Following this, there are N lines, each containing a string of length M consisting of the characters . and #.

Example:

3 3
...
...
...

outputFormat

Output a single integer representing the maximum area of the interior of the fort. If no valid frame is possible, output 0.

Example Output:

1

sample

3 3
...
...
...
1