#P7741. [AHOI2007] 石块地板
[AHOI2007] 石块地板
Problem Description
Xiao Keke arrives in the main hall of a palace. The floor of the hall is made of square stone tiles of the same size. These tiles are colored black or white, forming an rectangle. Under one of the tiles there is a passage leading to the treasure vault. Xiao Keke cannot try the tiles one by one, because some tiles have traps installed: touching them will trigger the mechanism and cause the entire palace to collapse.
According to the treasure map, the passage is within a specific area. This area is a small rectangle with non-zero area, made up of several tiles, and its four sides are parallel to the edges of the hall floor. If we consider all possible rectangles in the floor, then among all rectangles, this area has the maximum value of “number of black tiles minus number of white tiles”.
Xiao Keke wants to split the work with you: he will choose the area, and you will compute the difference between the numbers of black and white tiles. This way, the area containing the passage can be confirmed quickly and accurately. The treasure map says that none of the tiles in this area have traps installed, so once the area is determined, the passage will definitely be found. The treasure is right ahead, so good luck.
(Assume that represents a black tile, and represents a white tile.)
Input Format
The first line of the input file contains two integers .
The next lines each contain characters. Each character is either or .
Output Format
Output only one number, which is the maximum value of (as described above) among all possible areas. Output this value.
3 4
1011
1111
1111
10
4 5
10110
01111
11110
10101
8
Hint
For of the testdata: .
For of the testdata: .
Translated by ChatGPT 5