The topic gives a 01 matrix, which asks for the largest 1 sub-matrices.
With DP preprocessing the 1 of each column of each row can be extended up by a continuous number of 1, and then enumerate each row as the bottom of the sub-matrix, so the answer to each row is POJ2559 this classic question.
1#include <cstdio>2#include <cstring>3#include <algorithm>4 using namespacestd;5 #defineMAXN 22226 intSTACK[MAXN],TOP,L[MAXN],R[MAXN];7 intCalcint*a,intN) {8a[++n]=-1; top=0;9 for(intI=1; i<=n; ++i) {Tenl[i]=r[i]=i; One while(Top && a[stack[top]]>A[i]) { Ar[stack[top]]=i-1; -l[i]=L[stack[top]]; ---top; the } - if(Top && a[stack[top]]==a[i]) l[i]=L[stack[top]]; -stack[++top]=i; - } + intres=0; - for(intI=1; i<n; ++i) { +Res=max (res,a[i]* (r[i]-l[i]+1)); A } at returnRes; - } - intD[MAXN][MAXN]; - intMain () { - intn,m; - while(~SCANF ("%d%d",&n,&m)) { in for(intI=1; i<=n; ++i) { - for(intj=1; j<=m; ++J) scanf ("%d",&d[i][j]); to } + for(intI=1; i<=n; ++i) { - for(intj=1; j<=m; ++j) { the if(D[i][j]) d[i][j]=d[i-1][j]+1; * } $ }Panax Notoginseng intres=0; - for(intI=1; i<=n; ++i) { theRes=max (Res,calc (&d[i][0],m)); + } Aprintf"%d\n", res); the } + return 0; -}
POJ3493 largest submatrix of all 1 ' s (monotone stacks)