Codeforces554B:Ohana Cleans Up
B. Ohana Cleans Up
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
4
0101
1000
1111
0101
2
3
111
111
111
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的更多相关文章
- 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 ...
 - Ohana Cleans Up
		
Ohana Cleans Up Description Ohana Matsumae is trying to clean a room, which is divided up into an n ...
 - 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 站 ...
 
随机推荐
- jstl  小总结  以及 jstl fn
			
1.1.1 JSTL的使用 JSTL是JSP标准标签库.结合EL替换传统页面的<%%> * JSTL如果不会用.也是可以使用<%%>.但是一般在大公司使用JSTL.进入小公司. ...
 - Linux pthread
			
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h& ...
 - CentOS7 词典
			
goldendict sudo yum install goldendict打开goldendict,阅读welcome,添加本地词典,在http://abloz.com/huzheng/stardi ...
 - Spring的测试
			
spring测试要引用junit及spring-test <dependency> <groupId>junit</groupId> <artifactId& ...
 - 去掉input框点击时的默认颜色
			
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"> 5 < ...
 - ytu 1057: 输入两个整数,求他们相除的余数(带参的宏 + 模板函数 练习)
			
1057: 输入两个整数,求他们相除的余数 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 177 Solved: 136[Submit][Status ...
 - win10休眠选项在哪里设置?如何设置?
			
本人以前安装的Win7也是碰到这个问题 http://www.jb51.net/os/win10/373383.html 查询.打开休眠命令 1.右键开始菜单,选择命令提示符(管理员) 或 win+R ...
 - codeforces泛做..
			
前面说点什么.. 为了完成日常积累,傻逼呵呵的我决定来一发codeforces 挑水题 泛做.. 嗯对,就是泛做.. 主要就是把codeforces Div.1的ABCD都尝试一下吧0.0.. 挖坑0 ...
 - Leetcode Permutations
			
Given a collection of numbers, return all possible permutations. For example,[1,2,3] have the follow ...
 - Bug整理——$(window).height()获取到$(document).height()的问题
			
想看解决方案不想看无聊乏味的bug解决过程的同学,请直接跳转到页面底部~ 今天在做项目的过程中遇到了一个BUG,项目中需要获取到浏览器客户区的高度以方便做一些适应性调整,代码如下: $(documen ...