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;
}

【59.49%】【codeforces 554B】Ohana Cleans Up的更多相关文章

  1. JAVA 基础编程练习题49 【程序 49 子串出现的个数】

    49 [程序 49 子串出现的个数] 题目:计算字符串中子串出现的次数 package cskaoyan; public class cskaoyan49 { public static void m ...

  2. 【 BowWow and the Timetable CodeForces - 1204A 】【思维】

    题目链接 可以发现 十进制4 对应 二进制100 十进制16 对应 二进制10000 十进制64 对应 二进制1000000 可以发现每多两个零,4的次幂就增加1. 用string读入题目给定的二进制 ...

  3. 【52.49%】【codeforces 556A】Case of the Zeros and Ones

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【42.59%】【codeforces 602A】Two Bases

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【30.49%】【codeforces 569A】Music

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 776E】The Holmes Children

    [题目链接]:http://codeforces.com/contest/776/problem/E [题意] f(n)是小于n的不同整数对(x,y)这里x+y==n且gcd(x,y)==1的个数; ...

  7. 【codeforces 816A】Karen and Morning

    [题目链接]:http://codeforces.com/contest/816/problem/A [题意] 让你一分钟一分钟地累加时间; 问多长时间以后是个回文串; [题解] reverse之后如 ...

  8. 【codeforces 602D】Lipshitz Sequence

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

随机推荐

  1. AJAX - 基本流程和特点

    <script> window.onload = function(ev){ var oBtn = document.querySelector('button'); // querySe ...

  2. Spring学习总结(9)——Spring AOP总结

    spring IOC和AOP是Spring框架的两大核心基石,本文将对Spring AOP做一个系统的总结. 什么是AOP AOP(Aspect-Oriented Programming,面向切面编程 ...

  3. 5.Zookeeper的两种安装和配置(Windows):单机模式与集群模式

    转自:https://blog.csdn.net/a906998248/article/details/50815031

  4. C#中对XML的操作

    现在有一个xml文件,名称:BookStore.xml,数据如下: <?xml version="1.0" encoding="gb2312"?>& ...

  5. 【习题 6-11 UVA - 10410】Tree Reconstruction

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 可以先确定当前这棵子树的dfs序的范围. 然后第一个元素肯定是这棵子树的根节点. 那么只要在这棵子树的范围里面枚举节点. 看看有没有 ...

  6. Linux学习总结(4)——Centos6.5使用yum安装mysql——快速上手必备

    第1步.yum安装mysql [root@stonex ~]#  yum -y install mysql-server 安装结果: Installed:     mysql-server.x86_6 ...

  7. 各大免费邮箱邮件群发账户SMTP服务器配置及SMTP发送量限制情况

    网络产品推广和新闻消息推送时,经常用到的工具就是用客户邮箱发送邮件了,如果是要发送的邮件量非常大的话,一般的建议是搭建自己的邮局服务器,或者是花钱购买专业的邮件群发服务,免费邮箱的SMTP适合少量的邮 ...

  8. C++组合数(combination)的实现

    实现: (nm) 既需要计算组合的总数 (32)=3: 也需要分别获得每一种组合的情形,用于穷举搜索: 1, 2; 1, 3; 2, 3 1. 递归实现 // picked + toPick == m ...

  9. TPS54232-------电源管理芯片

    TPS54232 DC DC开关稳压器 电源管理芯片 放大器俗称功放 注意看芯片的次序1~8是如何排布的,这个规律一般是固定的 也许我们整理多了就能发现引脚的宽度和长度都是规格好的. 下面是封装: 所 ...

  10. GMTC2019会后:做一场冷门的技术专场是什么体验

    上周四(6.20)GMTC2019大会的第一天,很荣幸作为「UI与图形渲染」专场出品人获得了与图形领域几位技术专家同场交流的机会. 图形技术在前端范畴内是一个相对小众的话题,虽然前端工程师几乎每天都在 ...