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