// https://oj.uz/problem/view/IZhO17_bomb
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2505;
string a[N];
signed main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
///
int n, m;
cin >> n >> m;
int mx = m;
int my = n;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 0; i < n; ++i) {
int l = 0;
for (int j = 0; j < m; ++j) {
if (a[i][j] == '1') ++l;
else {
if (l) mx = min(mx, l);
l = 0;
}
}
if (l) mx = min(mx, l);
}
for (int j = 0; j < m; ++j) {
int l = 0;
for (int i = 0; i < n; ++i) {
if (a[i][j] == '1') ++l;
else {
if (l) my = min(my, l);
l = 0;
}
}
if (l) my = min(my, l);
l = 0;
}
cout << mx*my << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |