Submission #920198

#TimeUsernameProblemLanguageResultExecution timeMemory
920198MilosMilutinovicBomb (IZhO17_bomb)C++14
15 / 100
1040 ms600 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); 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)

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:49:31: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |     for(int i=0;i<n;i++) scanf("%s",s[i]);
      |                          ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...