time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

Ohana Matsumae is trying to clean a room, which is divided up into an n by n grid of squares. Each square is initially either clean or dirty. Ohana can sweep her broom over columns of the grid. Her broom is very strange: if she sweeps over a clean square, it will become dirty, and if she sweeps over a dirty square, it will become clean. She wants to sweep some columns of the room to maximize the number of rows that are completely clean. It is not allowed to sweep over the part of 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 will be a single integer n (1 ≤ n ≤ 100).

The next n lines will describe the state of the room. The i-th line will contain a binary string with n characters denoting the state of the i-th row of the room. 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 be a single line containing an integer equal to a maximum possible number of rows that are completely clean.

Examples

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 will make the 1st and 4th row be completely clean.

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

【题目链接】:http://codeforces.com/contest/554/problem/B

【题解】



因为最后肯定有一行是全为1的(全都是干净的);

那么就枚举最后哪一行全是干净的.

然后看看要让这一行全部是干净的需要把哪些列全部取反.

这样就能知道整个图有多少行是全为1的了;

取最大值就好.



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x)
#define pri(x) printf("%d",x)
#define prl(x) printf("%I64d",x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int MAXN = 100+10;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); int n;
int a[MAXN][MAXN];
char s[MAXN];
bool bo[MAXN]; int main()
{
//freopen("F:\\rush.txt","r",stdin);
rei(n);
rep1(i,1,n)
{
scanf("%s",s+1);
rep1(j,1,n)
a[i][j] = s[j]-'0';
}
int ans = 0;
rep1(i,1,n)
{
memset(bo,false,sizeof(bo));
rep1(j,1,n)
if (a[i][j]==0)
bo[j] = true;
int cnt = 0;
rep1(j,1,n)
{
bool ok = true;
rep1(k,1,n)
if ((a[j][k]==0 && !bo[k])||(a[j][k]==1 && bo[k]))
{
ok = false;
break;
}
if (ok) cnt++;
}
ans = max(ans,cnt);
}
cout << ans << endl;
return 0;
}

最新文章

  1. 你真的会玩SQL吗?三范式、数据完整性
  2. 【MVVM DEV】DataColumn中的TextBox与ComboBox的并存
  3. js正则匹配的一个日常应用
  4. 线程池之 Callable、Future、FutureTask
  5. 【UOJ #20】【NOIP 2014】解方程
  6. ajax 几种提交方式
  7. Python mongoDB 的简单操作
  8. 参数计数不匹配,未处理System.Reflection.TargetParameterCountException
  9. Csharp多态的实现概述
  10. 【学习笔记】tensorflow文件读取
  11. JS全局变量与局部变量
  12. JS重点整理之JS原型链彻底搞清楚
  13. C语言 &#183; 数字黑洞
  14. 阿里云 Ubuntu16.04 apache2 ssl证书下载与安装(必须有域名)
  15. BZOJ 4636: 蒟蒻的数列 分块
  16. HDU 4300 Clairewd’s message(扩展KMP)题解
  17. appium服务关键字
  18. jquery遍历-filter()
  19. vi基本状态
  20. 转动的八卦图纯css实现

热门文章

  1. codeforces 666E. Forensic Examination(广义后缀自动机,Parent树,线段树合并)
  2. 【2017 Multi-University Training Contest - Team 7】 Euler theorem
  3. HDU——T 2824 The Euler function
  4. 王小川分享AI
  5. graphicview和widgets没本质区别。它只是更轻量级,更灵活,性能更高的widgets
  6. jquery中prop()和attr()的使用
  7. oracle_经常使用分组函数
  8. oled stm32的spi
  9. js的AJAX请求有关知识总结
  10. Centos 6 vnc 部署