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
4
0101
1000
1111
0101
3
111
111
111
如果两行地砖状态完全相同,那么无论如何打扫,这两行地砖的状态始终都是完全相同的(因为打扫的时候必须打扫整列)。
要使最后整行为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的更多相关文章
- 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 ...
- Codeforces554B:Ohana Cleans Up
B. Ohana Cleans Up Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d Ja ...
- 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 ...
- 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 ...
- 贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up
题目传送门 /* 题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行 想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转 */ #include < ...
- 【59.49%】【codeforces 554B】Ohana Cleans Up
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- CodeForces 554B--Ohana Cleans Up
B. Ohana Cleans Up time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- Codeforces Round #309 (Div. 2)
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ha ...
- Java资源大全中文版(Awesome最新版)
Awesome系列的Java资源整理.awesome-java 就是akullpp发起维护的Java资源列表,内容包括:构建工具.数据库.框架.模板.安全.代码分析.日志.第三方库.书籍.Java 站 ...
随机推荐
- 注解:【有连接表的】Hibernate单向N->1关联
Person与Address关联:单向N->1,[有连接表的] Person.java package org.crazyit.app.domain; import javax.persiste ...
- HDU 5787 K-wolf Number 数位DP
K-wolf Number Problem Description Alice thinks an integer x is a K-wolf number, if every K adjacen ...
- OpenGL大作业
GLfloat light0_position[] = { 15.0,15.0,15.0,10.0 };//定义光源位置 103glLightfv(GL_LIGHT0, GL_POSITION, li ...
- loadrunner解决在项目中的难点解决
代码如下: vuser_init() { lr_save_string("11041331\",\"11041372\",\"11041373\&qu ...
- poj1061 Exgcd
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> usin ...
- Swift3.0语言教程使用指针创建和初始化字符串
Swift3.0语言教程使用指针创建和初始化字符串 Swift3.0语言教程使用指针创建和初始化字符串苹果的Swift团队花了不少功夫来支持C的一些基础特性.C语言中为我们提供了指针,Swift也不例 ...
- Smart原则
遵循smart原则,必须是具体的.可衡量的.可达到的.与岗位职责相关的.有明确达成期限的.
- 【CLR in c#】属性
1.无参属性 1.为什么有字段还需要属性呢? 因为字段很容易写出不恰当的代码,破坏对象的状态,比如Age=-1.人的年纪不可能为负数.使用属性后你可以缓存某些值或者推迟创建一些内部对象,你可以以线程安 ...
- Hive 实现HBase 数据批量插入
HBase 数据的插入可以使用Java API 来写Java 程序逐条倒入,但是不是很方便.利用Hive自带的一个Jar包,可以建立Hive和HBase的映射关系 利用Hive 的insert可以将批 ...
- Repeater 双向排序
做项目的时候,DataGrid ,DataList,Repeater 三个控件都是很优秀的数据显示控件,DataGrid的方便,简单易用,功能强大,但对性能会有所影响,在loading页面的时候大 ...