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