#P3331. [ZJOI2011] 礼物
[ZJOI2011] 礼物
Description
Xiaolan wants to give a unique handmade present for Xiaobai’s upcoming birthday. Specifically, Xiaolan has somehow made a wooden block (composed of unit cubes).
However, due to lack of skill, some unit cubes inside this block are defective (cracks, hollow inside, etc.), so Xiaolan cannot give it as-is. Xiaolan decides to carve out an sub-block from it (i.e., the carved rectangular block must have two adjacent edges of equal length). Of course, this sub-block must not contain any defective unit cubes.
To allow more patterns on the block, Xiaolan wants to choose, among all feasible plans, the one that maximizes the value of . But Xiaolan is exhausted after checking which unit cubes are defective. As Xiaolan’s friend, can you help?
Input Format
Each input file contains exactly one testdata.
The first line contains three positive integers separated by spaces.
Then there are lines, each containing characters. Each character is either P (Poor) or N (Nice), indicating whether the corresponding unit cube is defective or not. Specifically, in line number , the -th character describes the cube at coordinate .
Output Format
The output contains exactly one integer: the maximum possible value of .
3 2 5
PNNNN
PNNNN
NPPNP
PNNNP
NNNNP
PPNNP
24
Hint
For of the testdata, , and the input contains at least one N.
Translated by ChatGPT 5
京公网安备 11011102002149号