#309 (Div.2) b. Ohana cleans up

Source: Internet
Author: User

1. Title Description: Click to open the link

2. Solving ideas: The topic is a simple to find the maximum value problem. Just find the exact same line in the row and output it. Because the given range is small, it can be solved directly with O (n^3) algorithm. When looking for, use a mark array to mark which rows have been looked up, so that you can avoid duplicate lookups.

3. Code:

#define _crt_secure_no_warnings#include<iostream> #include <algorithm> #include <string> #include <sstream> #include <set> #include <vector> #include <stack> #include <map> #include < queue> #include <deque> #include <cstdlib> #include <cstdio> #include <cstring> #include < cmath> #include <ctime> #include <functional>using namespace std;typedef long Long ll;typedef unsigned Long long ull; #define ME (s) memset (s,0,sizeof (s)) #define for (i,n) for (int i=0;i< (n); i++) #define PB Push_back#define SZ size#define CLR Clear#define F (A, B) for (int. i=a;b;i++) int N;const int n=110;int vis[n][n];int main () {while (~SCANF ("            %d ", &n)) {for (int i=0;i<n;i++) {char s[n];            scanf ("%s", s);        for (int j=0;j<n;j++) vis[i][j]=s[j]-' 0 ';        } int mark[n];        int cnt=0;        Me (Mark);       int maxl=0;//maintain the maximum value of the same row found for (int i=0;i<n;i++)//Enumerate each row     if (!mark[i]) {Mark[i]=++cnt;//mark[i] indicates that line I is the mark[i] different row int num=1;//statistic and line I                       The exact same number of rows for (int j=i+1;j<n;j++) {int flag=1;                           for (int k=0;k<n;k++) if (Vis[j][k]!=vis[i][k]) {                       Flag=0;break;                       } if (flag) {mark[j]=cnt;num++;    }} Maxl=max (Maxl,num);//Update Max} printf ("%d\n", MAXL); } return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

#309 (Div.2) b. Ohana cleans up

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.