#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve () {
int n, m; cin >> n >> m;
vector <vector <char>> a(n + 1, vector <char> (m + 1));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> a[i][j];
}
}
int mx = 0;
for (int x = 1; x <= n; x++) {
for (int y = 1; y <= m; y++) {
vector <vector <int>> marked(n + 1, vector <int> (m + 1, 0));
for (int i = 1; i + x - 1 <= n; i++) {
for (int j = 1; j + y - 1 <= m; j++) {
int cnt = 0;
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
cnt += a[r][c] == '1';
}
}
if (cnt == x * y) {
for (int r = i; r <= i + x - 1; r++) {
for (int c = j; c <= j + y - 1; c++) {
marked[r][c] = 1;
}
}
}
}
}
bool flag = 1;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
if (a[i][j] == '1') {
flag &= marked[i][j];
}
}
}
if (flag) {
mx = max(mx, x * y);
}
}
}
cout << mx << '\n';
}
signed main () {
#ifndef ONLINE_JUDGE
// freopen("input_file", "r", stdin);
//freopen("output_file", "w", stdout);
#endif
ios::sync_with_stdio(0); cin.tie(0);
int tc = 1; //cin >> tc;
while (tc--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |