# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
920198 | MilosMilutinovic | Bomb (IZhO17_bomb) | C++14 | 1040 ms | 600 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.
// Online C++ compiler to run C++ program online
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[25][25];
bool was[25][25];
bool check(int x,int y){
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
was[i][j]=false;
}
}
for(int i=0;i+x<=n;i++){
for(int j=0;j+y<=m;j++){
bool ok=true;
for(int a=i;a<i+x;a++){
for(int b=j;b<j+y;b++){
if(s[a][b]=='0') ok=false;
}
}
if(ok){
for(int a=i;a<i+x;a++){
for(int b=j;b<j+y;b++){
was[a][b]=true;
}
}
}
}
}
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='1'&&!was[i][j]){
return false;
}
}
}
return true;
}
int main(){
scanf("%d%d",&n,&m);
if(n>20){
printf("0\n");
return 0;
}
for(int i=0;i<n;i++) scanf("%s",s[i]);
int lx=n;
int ly=m;
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
if(s[i][j]=='0') continue;
int ptr=j;
while(ptr+1<m&&s[i][ptr+1]=='1') ptr++;
ly=min(ly,ptr-j+1);
j=ptr;
}
}
for(int j=0;j<m;j++){
for(int i=0;i<n;i++){
if(s[i][j]=='0') continue;
int ptr=i;
while(ptr+1<n&&s[ptr+1][j]=='1') ptr++;
lx=min(lx,ptr-i+1);
i=ptr;
}
}
int ans=0;
for(int x=1;x<=lx;x++){
for(int y=1;y<=ly;y++){
if(check(x,y)) ans=max(ans,x*y);
}
}
printf("%d\n",ans);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |