CodeForces 554B--Ohana Cleans Up
2 seconds
256 megabytes
standard input
standard output
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.
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.
The output should be a single line containing an integer equal to a maximum possible number of rows that are completely clean.
4
0101
1000
1111
0101
2
3
111
111
111
3
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.
这题题意倒是很快就懂了,,但却没有什么思路直接跳下一题了。。错失一血(心痛3s)
题意:n*n的房间,n行n列个格子。每个格子初始为1代表干净,反之是脏的。小明可以每次清理一整列,次数不限,但此列原先干净的变成脏的,脏的变成干净的。问最多有多少行可以全部是干净的。(结合样例理解吧)
思路:求最多的行数,很容易想到最终符合条件的这些行的初始状态肯定是一样的,所以直接判断有多少行相同即可,直接用map存string计数。(也是看到有人一血后才瞬间知道题意做法。。)
const int N=1e5+10;
string a;
int main()
{
int n;
while(~scanf("%d",&n))
{
map<string,int>q;
q.clear();
int num=0;
for(int i=0;i<n;i++)
{
cin>>a;
q[a]++;
num=max(num,q[a]);
}
printf("%d\n",num);
}
return 0;
}
再次错失一血,,心痛10000s+
CodeForces 554B--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 ...
- 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 < ...
- CodeForces 554B(扫房间)
CodeForces 554B Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u ...
- Codeforces554B:Ohana Cleans Up
B. Ohana Cleans Up Time Limit: 2000ms Memory Limit: 262144KB 64-bit integer IO format: %I64d Ja ...
- Ohana Cleans Up
Ohana Cleans Up Description Ohana Matsumae is trying to clean a room, which is divided up into an n ...
- 【59.49%】【codeforces 554B】Ohana Cleans Up
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Round #309 (Div. 2)
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ha ...
随机推荐
- 使用 Realm 和 Swift 创建 ToDo 应用
原文出处: HOSSAM GHAREEB 译文出处:Prayer’s blog(@EclipsePrayer) 智能手机的快速发展的同时,涌现出了很多对开发者友好的开发工具,这些工具不仅使得开发变 ...
- TRUNCATE DELETE DROP 区别
TRUNCATE TABLE 在功能上与不带 WHERE 子句的 DELETE 语句相同:二者均删除表中的全部行.但 TRUNCATE TABLE 比 DELETE 速度快,且使用的系统和事务日志资源 ...
- sql server group by 分组带sum avg求和需要注意的一点
这是在写SQL语句遇到的一个sum 和group bu分组的问题
- ES6学习笔记(6)----函数的扩展
参考书<ECMAScript 6入门>http://es6.ruanyifeng.com/ 函数的扩展 函数的默认值 : ES6可以为函数指定默认值 (1)指定默认值的两种方式 a.函数参 ...
- EEPROM介绍
EEPROM( Electrically Erasable Programmable Read Only Memory )全称是电气可擦除可编程只读存储器,是非易失存储器,可以访问到每个字节,容量比较 ...
- iOS逆向实战与工具使用(微信添加好友自动确认)
iOS逆向实战与工具使用(微信添加好友自动确认) 原文链接 源码地址 WeChatPlugin-iOS Mac OS 版微信小助手(远程控制.消息防撤回.自动回复.微信多开) 一.前言 本篇主要实现在 ...
- java异常处理中的细节
首先看一段代码 public class Test{ public static String output=""; public static void foo(int i){ ...
- (三)docker 的启动,重启,关闭命令
docker启动命令,docker重启命令,docker关闭命令 启动 systemctl start docker 守护进程重启 sudo systemctl daemon-reload 重 ...
- ES6(vue)对象词法扩展
ES6 允许声明在对象字面量时使用简写语法,来初始化属性变量和函数的定义方法,并且允许在对象属性中进行计算操作: function getCar(make, model, value) { retur ...
- 关于Java的三种普通排序
首先要知道是哪几种排序 这里我们所说的是 冒泡排序,选择排序以及插入排序 然后要理解大概的排序速度 : 插入<选择<冒泡 下面是代码 大家可以拷贝自己在java环境里运行运行! publi ...