# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
38383 | Just_Solve_The_Problem | Bomb (IZhO17_bomb) | C++11 | 143 ms | 8144 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = (int)2505;
char c[N][N];
main () {
#define NAME "bomb"
// freopen(NAME".in", "r", stdin);
// freopen(NAME".out", "w", stdout);
bool fl = 1;
int n, m; scanf ("%d %d", &n, &m);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
char ss; ss = getchar();
if (ss == '\n')
j--;
else {
c[i][j] = ss;
if (ss == '1') fl = 0;
}
}
}
if (fl) {
puts("0");
return 0;
}
int h = N;
int w = N;
for (int i = 1; i <= n; i++) {
int res = 0;
for (int j = 1; j <= m; j++) {
if (c[i][j] == '0' && res != 0) {
w = min(w, res);
res = 0;
}
if (c[i][j] == '1')
res++;
}
if (res != 0)
w = min(w, res);
}
for (int i = 1; i <= m; i++) {
int res = 0;
for (int j = 1; j <= n; j++) {
if (c[j][i] == '0' && res != 0) {
h = min(h, res);
res = 0;
}
if (c[j][i] == '1')
res++;
// cout << j << ' ' << i << ' ' << res << endl;
}
if (res != 0)
h = min(h, res);
}
// cout << h << ' ' << w << endl;
cout << h * w;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |