Codeforces 375B Maximum Submatrix 2

Source: Internet
Author: User

Test instructions: give you a matrix that asks you only to change rows, to reach the maximum area of all the ' 1 ' matrices.

Problem-solving ideas: First row to find out the column of the longest continuous 1 how many, and then a column first hash and then find the maximum value, found%1d good slow.

Problem Solving Code:

1 //File name:375b.cpp2 //Author:darkdream3 //Created time:2015 March 09 Monday 21:05 00 seconds4 5#include <vector>6#include <list>7#include <map>8#include <Set>9#include <deque>Ten#include <stack> One#include <bitset> A#include <algorithm> -#include <functional> -#include <numeric> the#include <utility> -#include <sstream> -#include <iostream> -#include <iomanip> +#include <cstdio> -#include <cmath> +#include <cstdlib> A#include <cstring> at#include <ctime> - #defineLL Long Long - #defineMAXN 5005 - using namespacestd; - intDP[MAXN][MAXN]; - intHS[MAXN]; in intMain () { -     intN, M; toscanf"%d%d",&n,&m); + GetChar (); -      for(inti =1; I <= N;i + +) the     { *        intsum =0 ; $        Chartmp;Panax Notoginseng         for(intj =1; J <= M; j + +  ) -        { theTMP =GetChar (); +            if(TMP = ='1' ) ASum + + ;  the            Elsesum =0;  +DP[I][J] =sum; -        } $ GetChar (); $     } -     intMX =0 ;  -      for(inti =1; I <= M;i + +) the     { -memset (HS,0,sizeof(HS));Wuyi        for(intj=1; J <= N;j + +) the       { -Hs[dp[j][i]] + +; Wu       } -       intTsum =0 ;  About        for(intj =0; j<= M;j + +) $       { -          if(Hs[j]) -          { -MX = max ((n-tsum) *j, MX); ATsum + =Hs[j]; +          } the       } -     } $printf"%d\n", MX); the          the return 0; the}
View Code

Codeforces 375B Maximum Submatrix 2

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.