#P3331. Maximizing Craft Pattern Area

    ID: 16588 Type: Default 1000ms 256MiB

Maximizing Craft Pattern Area

Maximizing Craft Pattern Area

Little Bai's birthday is coming, and Little Lan wants to present a unique handmade craft gift. Little Lan has crafted a wooden block of size \(p \times q \times r\) (composed of \(pqr\) unit cubes). Unfortunately, some of these unit cubes are defective (they may have cracks or be hollow inside), and Little Lan cannot gift a block containing any defects.

To salvage the gift, Little Lan decides to carve out a subblock of size \(a \times a \times b\) (i.e. a rectangular cuboid with two adjacent equal sides) such that the carved subblock does not contain any defective unit cubes. Among all possible valid ways of carving out such a subblock, Little Lan wishes to choose one that maximizes the value of \(4ab\>.

Your task is to help Little Lan find the maximum possible value of \(4ab\) over all valid subblocks that can be carved out. If no valid subblock exists, output 0.

inputFormat

The first line contains three integers \(p\), \(q\), and \(r\) representing the dimensions of the wooden block. Then follow \(p\) blocks. Each block consists of \(q\) lines, and each line contains \(r\) integers (either 0 or 1) separated by spaces. A 0 indicates a good unit cube, and a 1 indicates a defective unit cube.

outputFormat

Output a single integer, the maximum value of \(4ab\) among all valid subblocks of shape \(a \times a \times b\) (with two adjacent sides equal) that contain no defects. If no valid subblock exists, output 0.

sample

2 2 2
0 0
0 0
0 0
0 0
16