#P11550. Monument
Monument
Monument
A wealthy millionaire from Sweden wants to build a monument for her family. Every ancestor (and every future descendant) will have their name engraved on it. The monument is a rectangular block with the top and bottom faces being squares of side length \(a\) and a height of \(b\). The area available on the four side faces is \(4ab\) and should be as large as possible to accommodate as many inscriptions as possible.
The monument must be carved out from a special rectangular stone of dimensions \(p\times q\times r\). The stone is made of small \(1\times1\times1\) unit blocks and may contain micro-pores (empty blocks). When cutting from the stone, cuts can only be made along the planes between the unit blocks (i.e. parallel to the \(x\), \(y\), or \(z\) axis). The final monument must consist entirely of solid (nonempty) unit blocks; it cannot include any pores.
Your task is to find, among all possible axis‐aligned sub-blocks that can be cut from the stone and that form a monument (with dimensions \(a\times a\times b\)), one with the maximum side area \(4ab\). Note that the monument may be oriented in any way such that one of the three dimensions serves as the height \(b\) and the other two serve as the sides of the square base \(a\times a\). If no valid monument exists, output 0.
Input/Output Format: See below.
inputFormat
The first line contains three integers \(p\), \(q\), and \(r\) (the dimensions of the stone).
Then follow \(p \times q\) lines. The stone is given layer by layer. Each layer consists of \(q\) lines, each line being a string of \(r\) characters. Each character is either '1' (a solid unit block) or '0' (a micro‐pore).
You may assume that \(p\), \(q\), and \(r\) are small enough for a brute force solution to pass.
outputFormat
Output a single integer: the maximum value of \(4ab\) that can be achieved by a valid monument cut from the stone. If no valid monument exists, output 0.
sample
1 1 1
1
4