Mock CCO '18 Contest 2 Problem 6 - Victor's Cubes

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 0.6s
Memory limit: 64M

Problem type

Roger, having now been bested twice in two dimensions, decides to move to three dimensions.

Roger has assembled a large block of stone, which has conveniently been subdivided into unit cubes that are either normal stones and paper. He challenges Victor to find a sub-block with a square base such that the entire sub-block contains no paper. The goal is to maximize the surface area of the components of the block perpendicular to one of the coordinate planes.

Constraints

1 \le A, B, C \le 150

Input Specification

The first line contains three integers, A, B, and C.

AB lines follow, each containing C characters. Character z on line 1 + yA + x - A corresponds to the cube that is located at (x, y, z), implying that all cubes lie in points (x, y, z) where 1 \le x \le A, 1 \le y \le B, and 1 \le z \le C. Each character is either N for normal stone or P for paper.

Output Specification

Output the maximum possible surface area of a valid block. In particular, the block must have dimensions a \times a \times b for some positive a and b, and the answer to output should be 4ab. The orientation of the valid block need not be such that the square base is parallel to the xy-plane.

Sample Input

3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP

Sample Output

24

Comments

There are no comments at the moment.