预处理没点向上最大伸展的1 num[i][j]
然后对于每行,按num[i][j]从大到小排序,即以他们为底最大1矩阵
1 #include2 #include 3 #include 4 using namespace std; 5 int a[1005][1005],num[1005][1005]; 6 int cmp(int x,int y) 7 { 8 return x>y; 9 }10 int main()11 {12 int n,m,i,j,maxx;13 while (~scanf("%d%d",&n,&m))14 {15 memset(num,0,sizeof(num));16 for (i=1;i<=n;i++)17 for (j=1;j<=m;j++)18 {19 scanf("%1d",&a[i][j]);20 if (a[i][j]) num[i][j]=num[i-1][j]+1; 21 }22 maxx=0;23 for (i=1;i<=n;i++)24 {25 sort(num[i]+1,num[i]+m+1,cmp);26 for (j=1;j<=m;j++)27 if (num[i][j]*j>maxx) maxx=num[i][j]*j;28 }29 printf("%d\n",maxx);30 }31 }
题目链接: