You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
825 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const int N = 110;
int n, m;
int a[N][N], s[N][N];
int res;
/*
4 5
1 1 0 0 0
1 0 1 0 0
0 0 0 1 1
0 0 0 1 0
6
*/
int main() {
cin >> n >> m;
for (int i = 1; i <= n; i++)
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
}
for (int x1 = 1; x1 <= n; x1++)
for (int y1 = 1; y1 <= m; y1++)
for (int x2 = x1 + 1; x2 <= n; x2++)
for (int y2 = y1 + 1; y2 <= m; y2++) {
if (s[x2][y2] - s[x1 - 1][y2] - s[x2][y1 - 1] + s[x1 - 1][y1 - 1] == 0)
res = max(res, (x2 - x1 + 1) * (y2 - y1 + 1));
}
printf("%d\n", res);
return 0;
}