# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1102960 | Muhammet | Bomb (IZhO17_bomb) | C++17 | 382 ms | 107948 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;
int n, m, a[N][N], b[N][N], c[N][N], d[N][N];
char e[N][N];
int main(){
cin >> n >> m;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> e[i][j];
}
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(e[i][j] == '1'){
a[i][j] = a[i][j-1] + 1;
}
else {
a[i][j] = 0;
}
}
}
for(int i = 1; i <= n; i++){
for(int j = m; j >= 1; j--){
if(e[i][j] == '1'){
b[i][j] = b[i][j+1] + 1;
}
else {
b[i][j] = 0;
}
}
}
for(int j = 1; j <= m; j++){
for(int i = 1; i <= n; i++){
if(e[i][j] == '1'){
c[i][j] = c[i-1][j] + 1;
}
else {
c[i][j] = 0;
}
}
}
for(int j = 1; j <= m; j++){
for(int i = n; i >= 1; i--){
if(e[i][j] == '1'){
d[i][j] = d[i+1][j] + 1;
}
else {
d[i][j] = 0;
}
}
}
int n1 = 1e9, m1 = 1e9;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
if(e[i][j] == '0') continue;
n1 = min(n1, (c[i][j] + d[i][j]) - 1);
m1 = min(m1, (a[i][j] + b[i][j]) - 1);
}
}
if(n1 == 1e9 and m1 == 1e9) cout << 0;
else cout << n1*m1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |