# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
682494 | HamletPetrosyan | Bomb (IZhO17_bomb) | C++17 | 432 ms | 6564 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 = 2505, INF = 1e9 + 5;
int n, m;
bool a[N][N], found = false;
int w = INF, h = INF;
int main(){
cin >> n >> m;
char x;
for(int i = 0; i < n; i++){
for(int j = 0; j < m; j++){
cin >> x;
a[i][j] = (x == '1');
found = found || (x == '1');
}
}
if(!found){
cout << n * m << "\n";
return 0;
}
int now = 0, np = INF;
for(int i = 0; i < n; i++){
now = 0;
for(int j = 0; j < m; j++){
if(!a[i][j]){
if(now) np = min(np, now);
now = 0;
}
else now++;
}
if(now) np = min(np, now);
}
w = np;
np = INF;
for(int i = 0; i < n; i++){
now = 0;
for(int j = 0; j < m; j++){
if(!a[j][i]){
if(now) np = min(np, now);
now = 0;
}
else now++;
}
if(now) np = min(np, now);
}
h = np;
cout << w * h << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |