Codeforces B. Ohana cleans up

Source: Internet
Author: User

B. Ohana cleans up

Ohana Matsumae is trying to the clean a-a, which is divided-to-a n by n grid of squares. Each square was initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom was very strange:if she sweeps over a clean square, it would become dirty, and if she sweeps over a dirty square, It'll become clean. She wants to sweep some columns of the and the number of rows that is maximize clean. It is not a allowed to sweep over the "the" column, Ohana can only sweep the whole column.

Return the maximum number of rows that she can make completely clean.

Input

The first line of input is a single integer n (1≤ n ≤100).

The next n Lines would describe the state of the The. The i-th line would contain a binary string with n characters denoting the state of the i-th Row of the. The J-th character on this line is ' 1 ' if the J-th Square in the i-th row is clean, and ' 0 ' if it is dirty.

Output

The output should is a single line containing an integer equal to a maximum possible number of rows that is completely cl Ean.

Sample Test (s) input
4
0101
1000
1111
0101
Output
2
Input
3
111
111
111
Output
3
Note

In the first sample, Ohana can sweep the 1st and 3rd columns. This'll make the 1st and 4th row is completely clean.

In the second sample, everything are already clean, so Ohana doesn ' t need to do anything.

/*Test Instructions: Select a few columns, then change these columns to 0 to 1, 1 to 0, and ask how many lines can be up to 1 ideas: Assuming the final answer includes line I, then if A[I][J] is 0, then the corresponding column J must be selected! For each row, make a column of 0 of the row as the selected column, and then iterate through the array, calculating the number of rows that are all 1. */#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>#include<string>#include<Set>using namespacestd;Chara[ the][ the], aa[ the][ the];intMain () {intN; scanf ("%d", &N);  for(intI=1; i<=n; ++i) {scanf ("%s", a[i]+1);  for(intj=1; j<=n; ++j) Aa[i][j]=A[i][j]; }    intAns =0;  for(intk=1; k<=n; ++k) {         for(intI=1; i<=n; ++i) {            if(a[k][i]=='0'){                 for(intj=1; j<=n; ++j)if(a[j][i]=='0') A[j][i]='1'; ElseA[j][i] ='0'; }        }        intSS =0;  for(intI=1; i<=n; ++i) for(intj=1; j<=n; ++j)if(A[i][j] = ='0')                     Break; Else if(j==N)++SS; if(Ans < ss) ans =SS;  for(intI=1; i<=n; ++i) for(intj=1; j<=n; ++j) A[i][j]=Aa[i][j]; } printf ("%d\n", ans); return 0;}

Codeforces 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.