Submission #171104

#TimeUsernameProblemLanguageResultExecution timeMemory
171104mosiashvililukaBomb (IZhO17_bomb)C++14
0 / 100
1097 ms61416 KiB
#include<bits/stdc++.h> using namespace std; int a,b,c,d,e,i,j,dp[2509][2509],zx,xc,qw,we,k[2509][2509],pas,dd; string s; bool f[2509][2509]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a>>b; for(c=1; c<=a; c++){ cin>>s; for(d=1; d<=b; d++){ f[c][d]=s[d-1]-'0'; } } for(c=1; c<=a; c++){ for(d=1; d<=b; d++) dp[c][d]=dp[c-1][d]+dp[c][d-1]-dp[c-1][d-1]+f[c][d]; } d=b; for(c=1; c<=a; c++){ while(d>=1){ // cout<<c<<" "<<d<<endl; bool bo=0; for(i=1; i<=a; i++) for(j=1; j<=b; j++) k[i][j]=0; for(i=c; i<=a; i++){ for(j=d; j<=b; j++){ qw=i-c+1;we=j-d+1; if(dp[i][j]-dp[i][we-1]-dp[qw-1][j]+dp[qw-1][we-1]==c*d){ k[qw][we]=1; } } } /* if(c==1&&d==5){ for(i=1; i<=a; i++){ for(j=1; j<=b; j++) cout<<k[i][j]<<" "; cout<<endl; } } if(c==1&&d==5) cout<<endl<<endl<<endl<<endl<<endl<<endl<<endl;*/ for(i=1; i<=a; i++){ for(j=1; j<=b; j++) k[i][j]=k[i-1][j]+k[i][j-1]-k[i-1][j-1]+k[i][j]; } /* if(c==1&&d==5){ for(i=1; i<=a; i++){ for(j=1; j<=b; j++) cout<<k[i][j]<<" "; cout<<endl; } }*/ for(i=1; i<=a; i++){ if(bo==1) break; for(j=1; j<=b; j++){ if(f[i][j]==0) continue; qw=i-c+1;we=j-c+1; if(qw<0) qw=0; if(we<0) we=0; int hj=0; if(qw!=0&&we!=0) hj=k[i][j]-k[qw-1][j]-k[i][we-1]+k[qw-1][we-1]; else hj=k[i][j]; if(hj==0){ bo=1; break; } } } if(bo==0){ if(pas<c*d) pas=c*d; break; } d--; } } cout<<pas; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...