Codeforces 554B ()

Source: Internet
Author: User

codeforces 554BTime limit:2000MS Memory Limit:262144KB 64bit IO Format:%i64d &%i6 4u

Description

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 Input

Input
4
0101
1000
1111
0101
Output
2
Input
3
111
111
111
Output
3


Puzzle: Given a n*n block tile paved room, each brick with 0 means not clean, 1 said has been cleaned. Require each sweep can only sweep a whole row of floor tiles, for one of the tiles did not clean will become cleaned, has been cleaned will become not clean. That is, 1 will become 0, and 0 will become 1, for a cleaning scheme, so that after cleaning the whole line of floor tiles have been cleaned the largest number of rows.

Seemingly no solution, but actually there is a solution, in fact, very simple.

First of all, it can be seen that if the two lines of tile state is exactly the same, then regardless of cleaning, the two lines of tile state is always the same (because cleaning must sweep the whole column). Thinking upside down, assuming that after cleaning some of the rows of tiles in the whole behavior of 1, then the row before cleaning the corresponding column of the tile state is exactly the same. So since we're going to make the last full 1 of the maximum number of rows, we're actually trying to start with the largest number of rows in the same state as the entire tile. The entire row is treated as a string and is directly implemented in map. Record the most frequently occurring string.



#include<stdio.h>#include<string.h>#include<algorithm>UsingNamespace Std;Char A[102][102];IntMax(int x,int y){If(x<y)Return y;Elsereturn x;}IntMain(){int n, IJK=0;scanf("%d", &n);For(I=1; I<=n; I++){scanf('%s 'A[I]);}For(I=1; I<=n; I++){int s=0;For(j=1; j<=n; j++){If(strcmp (A[i), A[j]) ==0 //comparison of two arrays s++; } k = max (k< Span class= "Sh-symbol" >,s); printf ( "% D\n ",k); return 0;}

Codeforces 554B ()

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.