/* Test instructions: give you a matrix with numbers only 0 and 12, where the columns can be moved arbitrarily. Asking how to move can make the element in a sub-matrix all 1, and find out the area of the largest sub-matrix. Each row is processed and then superimposed, to each row with Num[i] Note how many 1 for example: 1 0 1 1 num[i] The record is: 1 0 1 1 1 0 0 1 2 0 0 2 0 0 0 1 0 0 0 3 then to the num[i] from the big to the small row, the reading to the current line can get the maximum area. That is, the rightmost 1, and so on. So the biggest area of the current is Max (max,num[i]*i) */# include <stdio.h># include <algorithm># include <iostream># Include <string.h>using namespace Std;bool cmp (int x,int y) {return x>y;} Char a[1010][1010];int num[1010],ans[1010];int main () {int n,m,i,j,maxx,k; while (~SCANF ("%d%d", &n,&m)) {for (i=0; i<n; i++) scanf ("%s", &a[i]); memset (num,0,sizeof (num)); maxx=0; For (i=0, i<n; i++) {for (j=0; j<m; J + +) {if (a[i][j]== ' 1 ') num[j]++; else num[j]=0; ANS[J]=NUM[J]; } soRT (ANS,ANS+M,CMP); for (k=0; k<m; k++) Maxx=max (Maxx, (k+1) *ans[k]); } printf ("%d\n", Maxx); } return 0;}
HDU 2830 Matrix swapping II (movable column of the maximal complete sub-matrix)