#P4417. Maximizing Dinner Invitations
Maximizing Dinner Invitations
Maximizing Dinner Invitations
Mirko has bought an apartment and wants to invite as many people as possible to dinner with him. To celebrate, he plans to buy a large rectangular wooden table. The number of people a table can accommodate is equal to its perimeter, i.e. in mathematical notation: $$P = 2(\text{length} + \text{width})$$.
The table must be placed such that its edges are parallel to the edges of the apartment. The apartment layout is given as a grid of characters where a dot (.
) represents free space and a hash (#
) represents an obstacle. Your task is to find the maximum possible perimeter of a rectangle (table) that can be placed entirely in the free space.
inputFormat
The first line contains two integers R and C representing the number of rows and columns of the apartment layout. The next R lines each contain a string of C characters (each either .
or #
), which describe the layout.
outputFormat
Output a single integer - the maximum number of people that can be accommodated at the table, i.e. the maximum perimeter of any axis‐aligned rectangle that fits completely within free spaces.
sample
2 3
...
...
10