HDU 2830 Matrix swapping II (movable column of the maximal complete sub-matrix)

Source: Internet
Author: User

/* 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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.