B. Ohana Cleans Up

  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.

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

/*
题意:选中某几列, 然后将这些列中为0的变为1, 为1的变为0,问最多能有多少行全为1 思路:假设最终答案包括第i行,那么如果a[i][j] 之前为0,则对应的这一列 j 一定是被选中的!
对于每一行,将这一行某一列为0的列作为选中的列,然后再遍历一遍数组,计算全1的行的个数。
*/
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<string>
#include<set>
using namespace std;
char a[][], aa[][];
int main(){
int n;
scanf("%d", &n);
for(int i=; i<=n; ++i){
scanf("%s", a[i]+);
for(int j=; j<=n; ++j)
aa[i][j] = a[i][j];
}
int ans = ;
for(int k=; k<=n; ++k){
for(int i=; i<=n; ++i){
if(a[k][i]==''){
for(int j=; j<=n; ++j)
if(a[j][i]=='')
a[j][i]='';
else a[j][i] = '';
}
}
int ss = ;
for(int i=; i<=n; ++i)
for(int j=; j<=n; ++j)
if(a[i][j] == '')
break;
else if(j==n)
++ss;
if(ans < ss) ans = ss;
for(int i=; i<=n; ++i)
for(int j=; j<=n; ++j)
a[i][j] = aa[i][j];
}
printf("%d\n", ans);
return ;
}

codeforces B. Ohana Cleans Up的更多相关文章

  1. Codeforces Round #309 (Div. 2) B. Ohana Cleans Up 字符串水题

    B. Ohana Cleans Up Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/554/pr ...

  2. B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))

    B. Ohana Cleans Up   Ohana Matsumae is trying to clean a room, which is divided up into an n by n gr ...

  3. 贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up

    题目传送门 /* 题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行 想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转 */ #include < ...

  4. Codeforces554B:Ohana Cleans Up

    B. Ohana Cleans Up Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d      Ja ...

  5. Ohana Cleans Up

    Ohana Cleans Up Description Ohana Matsumae is trying to clean a room, which is divided up into an n  ...

  6. 【59.49%】【codeforces 554B】Ohana Cleans Up

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

  7. CodeForces 554B--Ohana Cleans Up

    B. Ohana Cleans Up time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #309 (Div. 2)

    A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ha ...

  9. CodeForces 554B(扫房间)

      CodeForces 554B Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u ...

随机推荐

  1. js 短信验证码 计时器

    $(function(){ getMsg(); //页面加载完成之后执行 }) function getMsg(){ //注册按钮的点击事件 $("#smsBtn").on(&qu ...

  2. javascript的变量声明提升

    这篇随笔是对网上文章的整理吸收 1. javascript的作用域是函数,不是块 2. 在函数内部,javascript解释器会把var变量提升到当前域的最前面,但是函数体不会提升. 看下面例子: v ...

  3. 关于媒体查询 @Media Screen 与响应式

    其实CSS2中已经有了媒体查询的概念,但是CSS3中媒体查询功能更加的强大! 首先,我们来看一个小例子 设置媒体查询的 Max Width ,改变窗口大小到600px的时候就会触发一下代码: @med ...

  4. jquery如何获取第一个或最后一个子元素?

    通过children方法,children("input:first-child") 1 2 $(this).children("input:first-child&qu ...

  5. 注册GitHub和源程序版本管理软件和项目管理软件的优缺点

    目前市面上主要源程序管理软件主要有:Microsoft TFS(Team Foundation Server).GitHub.Trac.BUGZILLA.Apple XCode.SVN Microso ...

  6. 正在运行的android程序,按home键之后退回到桌面,在次点击程序图标避免再次重新启动程序解决办法

    正在运行的android程序,按home键之后退回到桌面,在次点击程序图标避免再次重新启动程序解决办法 例如:一个android程序包含两个Activity,分别为MainActivity和Other ...

  7. HTML设计模式学习笔记

    本周我主要学习了HTML的设计模式,现将我的学习内容总结如下: 一.盒模型的学习 CSS中有一种基础的设计模型叫做盒模型,它定义了元素是如何被看做盒子来解析的.我主要学习了六种盒模型,分别为内联盒模型 ...

  8. Jmeter之参数化

    Jmeter参数化分为两类,一类是在badboy录制脚本时进行参数化,二是再Jmeter里进行参数化 一:badboy录制脚本时进行参数化的步骤 1.脚本录制成功后->在左下角,点击variab ...

  9. 体验phonegap3.0

    网上有各种各样的phonegap环境搭建资料,鉴于学习和整理的考虑,我还是把我搭建的过程整理出来 这篇文章中将涉及到的内容 PhoneGap环境需要的组件 Node环境 JDK Android SDK ...

  10. 初识Opserver,StackExchange的监控解决方案

    Opserver是闻名遐迩的网站Stack Overflow的开源监控解决方案,由Stack Exchange发布.它基于.NET框架构建,这在监控工具领域有些与众不同. 旨在为每个受监控系统的健康状 ...