Enumerate all rows. Then, for each row, record the number of 1 consecutive columns until this row. we can regard each column as 1 in width,
The continuous number is regarded as its height.
Then the problem can be seen as finding the largest rectangle in some adjacent rectangles with a height of 0, that is, the largest rectangle (HDU 1506)
It should be noted that the column can be arbitrarily moved, then the order of height from large to small is the optimal solution, and then B [I-1]> = B [I],
The area is obviously h [I] * I. Then enumeration.
[Cpp]
# Include <cstdio>
# Include <iostream>
# Include <cstring>
# Include <algorithm>
Using namespace std;
Int a [1010], B [1010];
Bool cmp (int t1, int t2)
{
Return t1> t2;
}
Int main ()
{
Int I, j, n, m, len, ans;
Char ch [1001];
While (scanf ("% d", & n, & m )! = EOF)
{
Memset (a, 0, sizeof ());
Ans = 0;
For (I = 1; I <= n; I ++)
{
Scanf ("% s", ch );
Len = strlen (ch );
For (j = 0; j <len; j ++)
{
If (ch [j] = '1 ')
A [j + 1] ++;
Else a [j + 1] = 0;
B [j + 1] = a [j + 1];
}
Sort (B + 1, B + 1 + m, cmp );
For (j = 1; j <= m & B [j]; j ++)
If (B [j] * j> ans) ans = B [j] * j;
}
Printf ("% d \ n", ans );
}
Return 0;
}