Give you a 01 matrix, find the largest of the 01 alternating matrices
Because n Max is only 100, so direct violent promiscuity
First, the line I, all columns up the legal length, and then enumerate the column J as the leftmost columns, calculate the maximum matrix can be obtained
/************************************************************************* > File name:2.cpp > Author:al ex > Mail: [email protected] > Created time:2015 May 07 Thursday 15:07 58 seconds ************************************** **********************************/#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <cstring>#include <cstdio>#include <cmath>#include <cstdlib>#include <queue>#include <stack>#include <map>#include <bitset>#include <set>#include <vector>using namespace STD;Const DoublePI =ACOs(-1.0);Const intINF =0x3f3f3f3f;Const DoubleEPS =1e-15;typedef Long LongLL;typedefPair <int,int> PLL;intok[ the][ the];classThematrix { Public:intMaxarea ( vector <string>MAT) {memset(OK,0,sizeof(OK));intn = mat.size ();intm = mat[0].length (); for(inti =0; I < m; ++i) {ok[i][0] =1; for(intj =1; J < N; ++J) {if(Mat[j][i] = = Mat[j-1][i]) {Ok[i][j] =1; }Else{Ok[i][j] = ok[i][j-1] +1;//the ith row of jth Col} } }intSize =0; for(inti =0; I < n; ++i) { for(intj =0; J < M; ++J) {intmins = Ok[j][i]; Size = max (size, mins);intFlag = Mat[i][j]-' 0 '; for(intK = j +1; K < M; ++K) {if(flag = = Mat[i][k]-' 0 ') { Break; } Flag ^=1; mins = min (mins, ok[k][i]); Size = max (size, (K-j +1) * mins); } } }returnSize }};
topcoder-srm610-div2-550 (Violent promiscuity)