parent
b9b2b793b9
commit
2905493de9
@ -0,0 +1,35 @@
|
||||
#include <bits/stdc++.h>
|
||||
using namespace std;
|
||||
const int N = 110;
|
||||
int a[N][N], s[N][N];
|
||||
/*
|
||||
4 5
|
||||
1 1 0 0 0
|
||||
1 0 1 0 0
|
||||
0 0 0 1 1
|
||||
0 0 0 1 0
|
||||
*/
|
||||
int main() {
|
||||
int n, m;
|
||||
cin >> n >> m;
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= m; j++)
|
||||
cin >> a[i][j];
|
||||
|
||||
// 计算二维前缀和
|
||||
for (int i = 1; i <= n; i++)
|
||||
for (int j = 1; j <= m; j++)
|
||||
s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + a[i][j];
|
||||
|
||||
int res = -1;
|
||||
for (int x1 = 1; x1 <= n; x1++)
|
||||
for (int y1 = 1; y1 <= m; y1++)
|
||||
for (int x2 = x1; x2 <= n; x2++)
|
||||
for (int y2 = y1; 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));
|
||||
}
|
||||
|
||||
cout << res << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue