Description
A 0/1 matrix that can cover all \ (1\) while not covering all \ (0\) of the matrix, making this area the largest.
Sol
dp/Suspension Line method.
First, the matrix must cover all the hanging lines of the welt.
By the method of suspension, the height of \ (r\) is the largest (c\), and the width is the maximum height of \ (c\).
Do it over and over, then update the statistical answer.
Up and down when the statistics are each height, about when the statistics are each width.
This will ensure that all matrices are a valid matrix.
I opened a few more arrays and found the space exploded ... And then I started to roll.
Code
/************************************************************** problem:3736 User:beiyu language:c++ Result : Accepted time:6888 ms memory:50412 kb****************************************************************/#include < ;cstdio> #include <cstring> #include <iostream>using namespace std; #define CLR (a) memset (A,0,sizeof (a)) #define DEBUG (a) cout<< #a << "=" <<a<< "Const int N = 2505; int n,m,ml,mw,s;int A[n][n],tmp[n][n],f[2][n],l[2][n],r[2][n],l[n],r[n];int Mxc[n],mxr[n]; void work (Int. mxc[]) {for (int j=1;j<=m;j++) l[0][j]=0,r[0][j]=m+1,f[0][j]=0; for (int i=1,cur=1;i<=n;i++) {l[0]=0,r[m+1]=m+1; for (int j=m;j;--j) if (A[i][j]) R[j]=r[j+1];else r[j]=j; for (int j=1;j<=m;j++) if (A[i][j]) {L[j]=l[j-1],f[cur][j]=f[cur^1][j]+1,l[cur][j]=max (l[cur^1][j],l[j]), R[cur ][j]=min (R[cur^1][j],r[j]); int r=f[cur][j],c=r[cur][j]-l[cur][j]-1; Mxc[r]=min (MXC[R],C); if (!a[i+1][j]) {for (int p=r+1;p<=n;p++) if (mxc[p]) Mxc[p]=0;else break; }}else l[j]=j,f[cur][j]=0,l[cur][j]=0,r[cur][j]=m+1; Cur^=1; }}int Main () {scanf ("%d%d", &n,&m); for (int i=1;i<=n;i++) {char Ch=getchar (), while (ch!= ' _ ' && ch!= ' X ') Ch=getchar (); for (int j=1;j<=m;j++) a[i][j]=ch== ' X ', Ch=getchar (); } ml=mw=n,s=0;memset (Mxc,0x3f,sizeof (MXC)), memset (mxr,0x3f,sizeof (MXR)); Work (MXC); for (int. j=1;j<=m;j++) for (int i=1;i<=n/2;i++) swap (a[i][j],a[n-i+1][j]); Work (MXC); for (int i=1;i<=n;i++) for (int j=1;j<=m;j++) tmp[j][i]=a[i][j],a[i][j]=0; for (int. i=1;i<=m;i++) for (int j=1;j<=n;j++) A[I][J]=TMP[I][J]; Swap (N,M); Work (MXR); for (int. j=1;j<=m;j++) for (int i=1;i<=n/2;i++) swap (a[i][j],a[n-i+1][j]); Work (MXR); Swap (N,M); mxr[0]=n+1; for (int. i=n,j=1;j<=m;j++) for (; i>mxr[j];--i) mxc[i]=min (mxc[i],j-1); for (int i=1;i<=n;i++) if (i*mxc[i]>s) s=i*mxc[i],ml=i,mw=mxc[i]; Printf("%d%d\n", ML,MW); return 0;}
Bzoj 3736: [Pa2013]karty