Ohana Cleans Up

Description

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 Input1

Input
4
0101
1000
1111
0101
Output
2
Sample Input2
Input
3
111
111
111
Output
3
 
题意:
   给定一个由n*n块地砖铺成的房间,每块砖用0表示未打扫,1表示已打扫。
 要求打扫时只能整列地扫,未打扫的会变为已打扫,已打扫的会变为未打扫。
即1会变成0,而0会变成1,
求一种打扫方案,使得打扫完后整行地砖均为已打扫的行数最大。
分析:

如果两行地砖状态完全相同,那么无论如何打扫,这两行地砖的状态始终都是完全相同的(因为打扫的时候必须打扫整列)。

要使最后整行为1的行数最大,就是求开始时整行地砖处于相同状态的行数最大。

所以只需将整行看做一个字符串,将出现最多的字符串的次数输出。

 #include<iostream>
#include<string>
using namespace std;
#define maxn 100
int n,count=;
string a[maxn];
int main()
{int x=;
cin>>n;
for(int i=;i<n;i++)
cin>>a[i];
for(int l=;l<n;l++)
{ count=;
for( int k=l;k<n;k++)
if(a[l]==a[k])
count++;
if(count>x)
x=count;
}
cout<<x<<endl;
return ;
}
 

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. Codeforces554B:Ohana Cleans Up

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

  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. 手机WebAPP设计注意事项和解决方法

    1. 基本手机网页设计 1.1 wap端的网站表头 wap端的网站,写的时候首先注意表头,因为是手机端的,所以和我们平常用的web端页面的不一样,表头为: 1.2 尽量少使用水平滚动. 水平滚动除了比 ...

  2. PMP 第五章 项目范围管理

    1.范围管理主要是干什么?什么是产品范围?什么是项目范围?    项目范围管理包括确保项目做而且只做成功完成项目所需的全部工作的各过程.管理项目范围主要是在定义和控制哪些工作应该包括在项目内,哪些不应 ...

  3. java 访问 usb

    java 要访问 usb 设备,通常要自己写c/c++代码,然后再用 java 访问这些组件,以达到控制usb设备的目的.但现在有一个开源组件 libusb 帮我们做好了访问usb设备的封装(包括wi ...

  4. How to use the Visual Studio

    推荐一个提供VS配色方案的一个网站:StudioStyles,域名和网站同名:http://studiostyl.es/ 2. 整行剪切:Ctrl + X.光标不要选中任何文字,然后按这个快捷键就可以 ...

  5. update comboBox

    /// <summary> /// AutoCompleteComboBox /// </summary> public class AutoCompleteComboBox ...

  6. jquery中append()、prepend()、after()、before()的区别详解

    append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标签之前添加东西) prepend() - 在被选元素的开头插入内容(内容的开始,比如说有个 ...

  7. 阿里云 OSS+CDN

    https://promotion.aliyun.com/ntms/ossedu2.html https://www.aliyun.com/act/aliyun/ossdoc.html 对象存储(Ob ...

  8. SpringMyBatis解析4-MapperScannerConfigurer

    如果有成百上千个dao接口呢,那我们岂不是要配置添加成百上千个bean,当然不是这样,spring还为MyBatis添加了拓展的功能,可以通过扫描包目录的方式,添加dao,让我看看具体使用和实现. & ...

  9. no-jquery 04 Events

    Events Sending Native (DOM) Events anchorElement.click(); Sending Custom Events var event = document ...

  10. http://www.cnblogs.com/summers/p/3225375.html

    http://www.cnblogs.com/summers/p/3225375.html