# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
388275 | patrikpavic2 | Bomb (IZhO17_bomb) | C++17 | 1097 ms | 12640 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 <cstdio>
#include <algorithm>
using namespace std;
const int N = 2505;
int n, m;
char s[N][N];
int main(){
//freopen("bomb.in", "r", stdin);
//freopen("bomb.out", "w", stdout);
scanf("%d%d", &n, &m);
for(int i = 0;i < n;i++)
for(int j = 0;j < m;j++)
scanf(" %c", &s[i][j]);
int ansi = n, ansj = m;
for(int i = 0;i < n;i++){
for(int j = 0;j < m;j++){
if(s[i][j] != '1') continue;
int il = i, ir = i;
int jl = j, jr = j;
while(il > 0 && s[il - 1][j] == '1') il--;
while(ir + 1 < n && s[ir + 1][j] == '1') ir++;
while(jl > 0 && s[i][jl - 1] == '1') jl--;
while(jr + 1 < m && s[i][jr + 1] == '1') jr++;
ansi = min(ansi, ir - il + 1);
ansj = min(ansj, jr - jl + 1);
}
}
printf("%d\n", ansi * ansj);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |