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. Java中List循环遍历的时候删除当前对象(自己)

    方法一 Java代码   ArrayList<String> list = new ArrayList<String>();           list.add(" ...

  2. Java提高篇(二七)-----TreeMap

    TreeMap的实现是红黑树算法的实现,所以要了解TreeMap就必须对红黑树有一定的了解,其实这篇博文的名字叫做:根据红黑树的算法来分析TreeMap的实现,但是为了与Java提高篇系列博文保持一致 ...

  3. linux查看某个进程的线程id(spid)

    鉴于linux下线程的广泛使用 我们怎么查看某个进程拥有的线程id了 现在很多服务的设计 主进程->子进程->线程(比如mysql,varnish) 主进程负责侦听网络上的连接 并把连接发 ...

  4. 获取系统开机的时间(Windows、Linux)

    获取系统启动的时间.Windows系统和Linux系统 1.Windows系统 1)代码如下 #include <stdio.h> #include <time.h> #inc ...

  5. SQL取行最大值

    create table T(A decimal(10,1), B decimal(10,1), C decimal(10,1), D decimal(10,1), E decimal(10,1)) ...

  6. HBase体系结构(转)

    HBase的服务器体系结构遵循简单的主从服务器架构,它由HRegion服务器(HRegion Server)群和HBase Master服务器(HBase Master Server)构成.HBase ...

  7. 检测电脑安装的net framework版本

    https://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx To find .NET Framework versions by ...

  8. 关于UIMenuController的使用 弹出菜单 UIMenuItem

    UIMenuController *menuController = [UIMenuController sharedMenuController];        UIMenuItem *menuI ...

  9. Matlab实现单变量线性回归

    一.理论 二.数据集 6.1101,17.592 5.5277,9.1302 8.5186,13.662 7.0032,11.854 5.8598,6.8233 8.3829,11.886 7.476 ...

  10. 开发H5小游戏

    Egret白鹭H5小游戏开发入门(一)   前言: 好久没更新博客了,以前很多都不会,所以常常写博客总结,倒是现在有点点经验了就懒了.在过去的几个月里,在canvas游戏框架方面,撸过了CreateJ ...