Submission #334310

#TimeUsernameProblemLanguageResultExecution timeMemory
334310juggernautBomb (IZhO17_bomb)C++14
0 / 100
1099 ms512 KiB
#include<bits/stdc++.h> using namespace std; template<class T>void umin(T& a,T b){if(b<a)a=b;} template<class T>void umax(T& a,T b){if(b>a)a=b;} int n,m,xx,yy,up[2505][2505],down[2505][2505],ans[2505]; bool ar[2505][2505]; char rd(){ char ch; do{ scanf("%c",&ch); }while(ch!='0'&&ch!='1'); } int main(){ scanf("%d%d",&n,&m); xx=n,yy=m; for(int i=1;i<=n;i++){ int cnt=0; for(int j=1;j<=m;j++){ ar[i][j]=(rd()=='1'); if(ar[i][j])cnt++; else{ if(cnt)umin(yy,cnt); cnt=0; } } if(cnt)umin(yy,cnt); } return 1; for(int j=1;j<=m;j++){ int cnt=0; for(int i=1;i<=n;i++){ if(ar[i][j]){ cnt++; up[i][j]=up[i-1][j]+1; }else{ if(cnt)umin(xx,cnt); cnt=0; } } if(cnt)umin(xx,cnt); for(int i=n;i>0;i--)if(ar[i][j])down[i][j]=down[i+1][j]+1; } for(int i=1;i<=yy;i++)ans[i]=xx; for(int i=1;i<=n;i++){ int cnt=0; int a=2e9,b=2e9; for(int j=1;j<=m;j++){ if(ar[i][j]){ umin(a,up[i][j]); umin(b,down[i][j]); umin(ans[++cnt],a+b-1); }else{ cnt=0; a=b=2e9; } } cnt=0; a=2e9,b=2e9; for(int j=m;j>0;j--){ if(ar[i][j]){ umin(a,up[i][j]); umin(b,down[i][j]); umin(ans[++cnt],a+b-1); }else{ cnt=0; a=b=2e9; } } } int res=ans[1]; for(int i=2;i<=yy;i++){ umin(ans[i],ans[i-1]); umax(res,i*ans[i]); } printf("%d",res); }

Compilation message (stderr)

bomb.cpp: In function 'char rd()':
bomb.cpp:12:1: warning: no return statement in function returning non-void [-Wreturn-type]
   12 | }
      | ^
bomb.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 |         scanf("%c",&ch);
      |         ~~~~~^~~~~~~~~~
bomb.cpp: In function 'int main()':
bomb.cpp:14:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     scanf("%d%d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...