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. 瀑布流布局——jquery

    首先确定定位,因为.box的宽度是确定的,根据屏幕的宽度来调整.box的列数,所以#content的宽度是随着.box的列数变化而变化的,并且需要保持相对于body居中. 因此需要给#content添 ...

  2. CentOS7中禁用IPV6

    helps from: https://linux.cn/article-4935-1.html vi /etc/sysctl.conf net.ipv6.conf.all.disable_ipv6 ...

  3. mint17.3挂载u盘出现错误:mount:unknown filesystem type 'exfat'

    mint17.3挂载u盘出现错误:mount:unknown filesystem type 'exfat' 安装exfat-fuse: sudo apt-get install exfat-fuse

  4. MVC 前台获取三级菜单及子菜单

    1.在后台将所有的菜单获取出来,代码如下: public ActionResult Index() { //所有商品分类 var oneMenu = _baseGoodsCategory.FindLi ...

  5. Android中Input型输入设备驱动原理分析(一)

    转自:http://blog.csdn.net/eilianlau/article/details/6969361 话说Android中Event输入设备驱动原理分析还不如说Linux输入子系统呢,反 ...

  6. 算法系列:FFT 003

    转载自https://zhuanlan.zhihu.com/p/19763358 作者:Heinrich 链接:https://zhuanlan.zhihu.com/p/19763358 来源:知乎 ...

  7. node+fis3搭建

    node安装: 到https://nodejs.org/en/download/releases下载编译好的包, 如:https://nodejs.org/download/release/v4.4. ...

  8. 在ASP.NET MVC项目中使用React

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:最近在开发钉钉的微应用,考虑到性能和UI库的支持,遂采用了React来开发前端. 目前 ...

  9. TextSwitcher 简单用例

    TextSwitcher 字面理解是文字交换器,是ViewSwitcher的子类,从ViewSwitcher来看,是View交换器,TextSwitcher继承自ViewSwitcher,显然是交换T ...

  10. 浅谈SQLiteOpenHelper之onUpgrade例子

    当你看到这个博文,首先你要了解onCreate这个创建方法,再来继续下文!(可以参考我的上一个博文http://www.cnblogs.com/896240130Master/p/6119616.ht ...