Baltic Olympiad in Informatics: 2009 Day 2, Problem 3
A Swedish millionaire wants to build a monument for her family. The names of all of her known ancestors (and later, her future descendants) will be inscribed to the sides of the monument. The form of the monument will be a rectangular block with
The monument will be cut from a very special
The raw stone contains pores, in the form of empty unit cubes. The monument is required to be of high quality and is thus not allowed to contain any pores (empty unit cubes). You are given a 3D-map of the raw stone. The map describes which unit cubes are normal and which empty. Your task is to find such values for the size parameters
it is possible to cut the monument out of the supplied raw stone block, and
the monument contains the maximal amount of space on its four sides, that is, the value
is as large as possible.
Input Specification
The first line of input contains three positive space-separated integers: the values N
(normal) or P
(pore). The
Output Specification
Output one integer on one line, containing the maximal value of
Sample Input
3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP
Sample Output
24
Comments