#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define FOR(i, a) for (int i = 0; i < (a); i++)
#define F0R(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i,a) for (int i = (a)-1; i >= 0; i--)
#define F0Rd(i,a,b) for (int i = (b); i >= (a); i--)
#define trav(a, x) for (auto& a : x)
const int N = 2506;
char c[N][N];
int prdz[N][N], praj[N][N], ans1, ans2, pr[N];
void ad(int a, int b){
//cout << a << " " << b << endl;
if (a > ans2 || b > ans1)return;
pr[a] = min(pr[a], b);
}
int main(){
ios_base::sync_with_stdio(false);
int n, m;
cin >> n >> m;
for (int i = 0; i<n; i++){
cin >> c[i];
pr[i] = INT_MAX;
}
pr[n] = INT_MAX;
int mn = INT_MAX;
for (int i = 0; i<n; i++){
int tv = 0;
for (int j = 0; j<m; j++){
if (c[i][j] == '1'){
if (j == 0)prdz[i][j] = 1;
else prdz[i][j] = prdz[i][j - 1] + 1;
tv++;
}
else if (tv != 0){
mn = min(mn, tv);
tv = 0;
}
}
for (int j = m - 1; j >= 0; j--){
if (c[i][j] == '1'){
praj[i][j] = praj[i][j + 1] + 1;
}
}
if (tv != 0)mn = min(mn, tv);
}
ans1 = mn;
mn = INT_MAX;
for (int j = 0; j<m; j++){
int tv = 0;
for (int i = 0; i<n; i++){
if (c[i][j] == '1'){
tv++;
}
else if (tv != 0){
mn = min(mn, tv);
tv = 0;
}
}
if (tv != 0)mn = min(mn, tv);
}
ans2 = mn;
//cout << ans1 << " " << ans2 << endl;
for (int j = 0; j < m; j++){
for (int i = 0; i < n; i++){
if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
int ans = INT_MAX,k=0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, praj[i][j]);
ad(k, ans);
i++;
}
i--;
}
else if (c[i][j]=='1' &&(j==m-1 || c[i][j+1]=='0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, prdz[i][j]);
ad(k, ans);
i++;
}
i--;
}
}
}
for (int j = 0; j<m; j++){
for (int i = n-1; i >= 0; i--){
if (c[i][j] == '1' && (j == 0 || c[i][j - 1] == '0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, praj[i][j]);
ad(k, ans);
i--;
}
i++;
}
else if (c[i][j] == '1' && (j == m - 1 || c[i][j + 1] == '0')){
int ans = INT_MAX, k = 0;
while (i<n && c[i][j] == '1'){
k++;
ans = min(ans, prdz[i][j]);
ad(k, ans);
i--;
}
i++;
}
}
}
int verj = 1;
for (int i = 1; i <= n; i++){
if (pr[i] == INT_MAX)continue;
verj = max(verj, i*pr[i]);
}
cout << verj << endl;
return 0;
}
/*
5 6
001000
111110
111110
111110
000100
*/
Compilation message
bomb.cpp: In function 'int main()':
bomb.cpp:32:11: error: 'INT_MAX' was not declared in this scope
pr[i] = INT_MAX;
^~~~~~~
bomb.cpp:32:11: note: suggested alternative: 'INT8_MAX'
pr[i] = INT_MAX;
^~~~~~~
INT8_MAX
bomb.cpp:34:10: error: 'INT_MAX' was not declared in this scope
pr[n] = INT_MAX;
^~~~~~~
bomb.cpp:34:10: note: suggested alternative: 'INT8_MAX'
pr[n] = INT_MAX;
^~~~~~~
INT8_MAX