topcoder-srm610-div2-550 (Violent promiscuity)

Source: Internet
Author: User

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)

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.