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. Uncaught ReferenceError: console is not defined

    今天写javascript代码遇到了这个极其神奇的问题,居然报错说内置的console不存在,而且后来我换成了alert也不行.照例说这些都是js代码内置的东西不应该出现这种错误.不过百度之发现貌似没 ...

  2. String之-如何取得精确byte长度字符串

    背景:公司生产线上出现异常,报的错是记录日志时数据库长度超出,导致异常,经查询发现是由于在计算byte长度时出了问题. 问题代码: operatorLog.setOperAfterData(updat ...

  3. 静态/动态函数库设计,王明学learn

    静态/动态函数库设计 Linux应用程序设计中需要的外部函数主要由函数库和系统调用来提供. 两者区别: 一.函数库分类 函数库按照链接方式可分为: 1.静态链接库 对函数库的链接是放在编译时期(com ...

  4. Arduino101学习笔记(五)—— 模拟IO

    1.配置IO管脚 //***************************************************************************************** ...

  5. VisualStudio一打开工程就崩溃-重打开output显示We were unable to automatically populate your Visual Studio Online accounts.

    and this method exactly effected on me

  6. centos7 卸载mysql

    [root@zyf ~]# rpm -qa|grep -i mysql mysql-community-libs--.el7.x86_64 mysql-community-server--.el7.x ...

  7. loadrunner获取本机的机器名称

  8. 在C#程序中实现插件架构

    阅读提示:这篇文章将讲述如何利用C#奇妙的特性,实现插件架构,用插件(plug-ins)机制建立可扩展的解决方案. 在.NET框架下的C#语言,和其他.NET语言一样提供了很多强大的特性和机制.其中一 ...

  9. Http协议提要

    HTTP协议提要 简单来说,HTTP就是一个基于应用层的通信规范:双方要进行通信,大家就要遵守一个规范---HTTP协议.HTTP协议从WWW服务器超文本到本地浏览器 ,可以使浏览器更加高效.HTTP ...

  10. JAVA 加减乘除

    package homework; import javax.swing.JOptionPane; public class suanshu { public static void main(Str ...