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

1A,B,C150

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+xA corresponds to the cube that is located at (x,y,z), implying that all cubes lie in points (x,y,z) where 1xA, 1yB, and 1zC. 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×a×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

Copy
3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP

Sample Output

Copy
24

Comments

There are no comments at the moment.