B. Ohana Cleans Up

Time Limit: 2000ms
Memory Limit: 262144KB

64-bit integer IO format: %I64d      Java class name: (Any)

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 Input

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

Hint

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.

题目大意:有一个广场   n*n大小,0表示不干净,1表示干净,有一个神奇厉害的大妈,每次扫地只扫一列,扫完之后,干净变成不干净,不干净变成干净(如此神奇),问最多能使得几行变得干净。

思路:遍历一遍即可,看看最多有几行是相同的。用vi[i]保存遍历过的,防止重复搜索。

代码:

#include <stdio.h>
#include <iostream>
#include <string.h> using namespace std; int main(){
char s[][];
int vi[]={};
int max=;
int num=;
int n;
cin>>n;
for(int i=;i<n;i++)
cin>>s[i];
for(int i=;i<n;i++){
num=;
if(vi[i]==)
continue;
vi[i]=;
for(int j=;j<n ;j++){
if(strcmp(s[i],s[j])==){num++;vi[j]=;}
}
if(max<num)
max=num;
}
cout<<max;
}

Codeforces554B:Ohana Cleans Up的更多相关文章

  1. codeforces B. Ohana Cleans Up

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

  2. Ohana Cleans Up

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

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

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

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

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

  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. Java资源大全中文版(Awesome最新版)

    Awesome系列的Java资源整理.awesome-java 就是akullpp发起维护的Java资源列表,内容包括:构建工具.数据库.框架.模板.安全.代码分析.日志.第三方库.书籍.Java 站 ...

随机推荐

  1. 【ZJOI2007】棋盘制作 BZOJ1057

    Description 国 际象棋是世界上最古老的博弈游戏之一,和中国的围棋.象棋以及日本的将棋同享盛名.据说国际象棋起源于易经的思想,棋盘是一个8*8大小的黑白相间的方 阵,对应八八六十四卦,黑白对 ...

  2. 关于git的简单实用命令

    时代在进步啊,现在已经不是svn的时代了,好多人都在使用git.所以自己也稍微学习了下git的使用. 常见的通过git提交代码步骤: git status :查看文件状态 :该命令显示你工程内修改的所 ...

  3. SQL Server 2008登录错误:无法连接到(local)解决方法

    在一些朋友安装完SQL Server 2008之后大多会遇到连接出错的问题比如:SQL Server 2008登录错误:无法连接到(local)等等相关问题,本文将详细介绍解决方法,需要的朋友可以参考 ...

  4. python logging模块笔记

    1 ) 给logger定制了两个日志级别INFO和DEBUG,分别通过filehandler添加不同输出到不同文件,但如何让DEBUG里只有DEBUG的信息? 答案:可重写DEBUG对应的Fileha ...

  5. virtualbox

    下载安装:http://wiki.centos.org/zh/HowTos/Virtualization/VirtualBox

  6. Jquery点击本身,修改出本身之外的其他同级元素的样式

    1.引用Jquyer库 2.Jquery代码: <script type="text/javascript"> $(function () { slidColor('d ...

  7. 转:Autodesk 2017软件下载+注册机+破解方法(持续更新)

    转载自http://blog.sina.com.cn/s/blog_710225790102w03e.html Autodesk 2017安装步骤: 安装Autodesk 2017相关软件 使用序列号 ...

  8. seajs和requirejs

    一.seajs 1. 使用seajs的一般步骤 a)在主页面引入sea.js b)写模块 c)在主页面使用模块 2.模块的写法 math.js define(function(require, exp ...

  9. Runnable接口

    Runnable接口的说用是使线程不仅可以继承Thread类实现,还可以继承其他类(比如:JFrame). 此接口具有两个构造方法: (1)public Thread(Runnable r) (2)p ...

  10. CSS后代选择器可能的错误认识

    一.关于类选择器的一个问题 CSS代码: .red { color: red; } .green { color: green; } HTML代码: <div class="red&q ...