Submission #88109

#TimeUsernameProblemLanguageResultExecution timeMemory
88109PajarajaBomb (IZhO17_bomb)C++17
43 / 100
1096 ms69340 KiB
#include <bits/stdc++.h> #define MAXN 2507 using namespace std; bool t[MAXN][MAXN],r[MAXN][MAXN]; int p[MAXN][MAXN],d[MAXN][MAXN],n,m; char s[MAXN][MAXN]; bool provera(int x,int y) { for(int i=x;i<=n;i++) for(int j=y;j<=m;j++) r[i][j]=(p[i][j]-p[i-x][j]-p[i][j-y]+p[i-x][j-y]==x*y); for(int i=n;i>0;i--) for(int j=m;j>0;j--) d[i][j]=r[i][j]+d[i+1][j]+d[i][j+1]-d[i+1][j+1]; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) if(t[i][j] && d[i][j]-d[min(n+1,i+x)][j]-d[i][min(m+1,j+y)]+d[min(n+1,i+x)][min(m+1,j+y)]==0) return false; return true; } int main() { int lh=2507,lv=2507; scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) { scanf("%s",s[i]); for(int j=1;j<=m;j++) t[i][j]=(s[i][j-1]=='1'?1:0); } for(int i=1;i<=n;i++) { int cur=0; for(int j=1;j<=m;j++) { if(t[i][j]==0) {if(cur!=0) lh=min(lh,cur); cur=0;} else cur++; } if(cur!=0) lh=min(lh,cur); } for(int i=1;i<=m;i++) { int cur=0; for(int j=1;j<=n;j++) { if(t[j][i]==0) {if(cur!=0) lv=min(lv,cur); cur=0;} else cur++; } if(cur!=0) lv=min(lv,cur); } int sol=0; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) p[i][j]=t[i][j]+p[i-1][j]+p[i][j-1]-p[i-1][j-1]; for(int i=1;i<=lv;i++) { while(!provera(i,lh)) lh--; if(sol>lh*n) break; sol=max(sol,lh*i); } printf("%d",sol); }

Compilation message (stderr)

bomb.cpp: In function 'int main()':
bomb.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&m);
  ~~~~~^~~~~~~~~~~~~~
bomb.cpp:20:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",s[i]);
   ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...