Submission #920196

#TimeUsernameProblemLanguageResultExecution timeMemory
920196MilosMilutinovicBomb (IZhO17_bomb)C++14
15 / 100
1053 ms2904 KiB
// 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);
    for(int i=0;i<n;i++) scanf("%s",s[i]);
    int ans=0;
    for(int x=1;x<=n;x++){
        for(int y=1;y<=m;y++){
            if(check(x,y)) ans=max(ans,x*y);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Compilation message (stderr)

bomb.cpp: In function 'int main()':
bomb.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   44 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
bomb.cpp:45:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |     for(int i=0;i<n;i++) scanf("%s",s[i]);
      |                          ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...