This is a maximum of 0 sub-matrices and a maximum of 0 sub-squares but change the 0 to 01 intervals, so I put a M into N and half.
1#include <cstdio>2#include <cstring>3#include <iostream>4#include <cstdlib>5#include <algorithm>6#include <queue>7 #defineM 20098 #definell Long Long9 #defineMo 12345678Ten using namespacestd; One ll Read () A { - CharCh=GetChar (); -ll x=0, f=1; the for(;ch<'0'|| Ch>'9'; ch=GetChar ()) - if(ch=='-') -f=-1; - for(; ch>='0'&&ch<='9'; ch=GetChar ()) +x=x*Ten+ch-'0'; - returnx*F; + } A intn,m,a[m][m],f[m][m],h[m],ans=1, l[m],r[m]; at intMain () - { -n=read (); -m=read (); - for(intI=1; i<=n;i++) - for(intj=1; j<=m;j++) ina[i][j]=read (); - for(intI=1; i<=n;i++) to { + intH=0; - for(intj=1; j<=m;j++) the { * if(a[i][j]==a[i][j-1]) $H=1;Panax Notoginseng Else -h++; the if(a[i][j]==a[i-1][j]) +h[j]=1; A Else theh[j]++; + if(a[i][j]==a[i-1][j-1]) -F[i][j]=min (H,min (f[i-1][j-1]+1, H[j])); $ Else $f[i][j]=1; -ans=Max (ans,f[i][j]); - } the } -printf"%d\n", ans*ans);Wuyians=0; thememset (H,0,sizeof(H)); -l[1]=1; Wur[m]=m; - for(intI=1; i<=n;i++) About { $ for(intj=1; j<=m;j++) - if(a[i][j]==a[i-1][j]) -h[j]=1; - Else Ah[j]++; + for(intj=2; j<=m;j++) the if(a[i][j-1]!=a[i][j]&&h[j-1]>=H[j]) -l[j]=l[j-1]; $ Else thel[j]=J; the for(intj=1; j<=m;j++) the for(; a[i][l[j]-1]!=a[i][l[j]]&&h[l[j]-1]>=h[j]; l[j]=l[l[j]-1]); the for(intj=m-1; j;j--) - if(a[i][j+1]!=a[i][j]&&h[j+1]>=H[j]) inr[j]=r[j+1]; the Else ther[j]=J; About for(intj=m;j;j--) the for(; a[i][r[j]+1]!=a[i][r[j]]&&h[r[j]+1]>=h[j]; r[j]=r[r[j]+1]); the for(intj=1; j<=m;j++) theAns=max ((r[j]-l[j]+1)*H[j],ans); + } -printf"%d\n", ans); the return 0;Bayi}
Bzoj 1057: [ZJOI2007] Board making