B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))
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.
题意:每次改变一列的值(0变1,1变0)问最后最大有多少行全为1。
思路:不须要管全一或者全零由于他们是能够相互转换的,所以仅仅要比較初始状态,每行状态,取最多的就好了。
题目链接:http://codeforces.com/contest/554/problem/B
转载请注明出处:寻找&星空の孩子
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; char a[105][105]; int main()
{
int n,i,j,ans = 0;
scanf("%d",&n);
for(i = 0;i<n;i++)
{
scanf("%s",a[i]);
}
for(i = 0;i<n;i++)
{
int s = 0;
for(j = 0;j<n;j++)
{
if(strcmp(a[i],a[j])==0)
s++;
}
ans = max(ans,s);
}
printf("%d\n",ans);
}
B. Ohana Cleans Up(Codeforces Round #309 (Div. 2))的更多相关文章
- A. Kyoya and Photobooks(Codeforces Round #309 (Div. 2))
A. Kyoya and Photobooks Kyoya Ootori is selling photobooks of the Ouran High School Host Club. He ...
- 【CodeForces】841D. Leha and another game about graph(Codeforces Round #429 (Div. 2))
[题意]给定n个点和m条无向边(有重边无自环),每个点有权值di=-1,0,1,要求仅保留一些边使得所有点i满足:di=-1或degree%2=di,输出任意方案. [算法]数学+搜索 [题解] 最关 ...
- B. The Number of Products(Codeforces Round #585 (Div. 2))
本题地址: https://codeforces.com/contest/1215/problem/B 本场比赛A题题解:https://www.cnblogs.com/liyexin/p/11535 ...
- 【CodeForces】841C. Leha and Function(Codeforces Round #429 (Div. 2))
[题意]定义函数F(n,k)为1~n的集合中选择k个数字,其中最小数字的期望. 给定两个数字集A,B,A中任意数字>=B中任意数字,要求重组A使得对于i=1~n,sigma(F(Ai,Bi))最 ...
- D. Zero Quantity Maximization ( Codeforces Round #544 (Div. 3) )
题目链接 参考题解 题意: 给你 整形数组a 和 整形数组b ,要你c[i] = d * a[i] + b[i], 求 在c[i]=0的时候 相同的d的数量 最多能有几个. 思路: 1. 首先打开 ...
- Vus the Cossack and Strings(Codeforces Round #571 (Div. 2))(大佬的位运算实在是太强了!)
C. Vus the Cossack and Strings Vus the Cossack has two binary strings, that is, strings that consist ...
- CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))
题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发 问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候 如果对于一条边 ...
- 贪心+构造( Codeforces Round #344 (Div. 2))
题目:Report 题意:有两种操作: 1)t = 1,前r个数字按升序排列: 2)t = 2,前r个数字按降序排列: 求执行m次操作后的排列顺序. #include <iostream&g ...
- B. Complete the Word(Codeforces Round #372 (Div. 2)) 尺取大法
B. Complete the Word time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
随机推荐
- bzoj1402 Ticket to Ride 斯坦纳树 + 状压dp
给定\(n\)个点,\(m\)条边的带权无向图 选出一些边,使得\(4\)对点之间可达,询问权值最小为多少 \(n \leqslant 30, m \leqslant 1000\) 首先看数据范围,\ ...
- 仅100行的JavaScript DOM操作类库
如果你构建过Web引用程序,你可能处理过很多DOM操作.访问和操作DOM元素几乎是每一个Web应用程序的通用需求.我们我们经常从不同的控件收集信息,我们需要设置value值,修改div或span标签的 ...
- python学习两月总结_汇总大牛们的思想_值得收藏
下面是我汇总的我学习两个月python(version:3.3.2)的所有笔记 你可以访问:http://www.python.org获取更多信息 你也可以访问:http://www.cnblogs. ...
- Codeforces Round #243 (Div. 1)A. Sereja and Swaps 暴力
A. Sereja and Swaps time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 预处理
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- poj 1218 THE DRUNK JAILER
THE DRUNK JAILER Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 23358 Accepted: 1472 ...
- spring---aop(3)---Spring AOP的拦截器链
写在前面 时间断断续续,这次写一点关于spring aop拦截器链的记载.至于如何获取spring的拦截器,前一篇博客已经写的很清楚(spring---aop(2)---Spring AOP的JDK动 ...
- lamp经典安装
一.网络方面的知识 2 ①-网络常见的命令 2 ②-网卡相关 2 ③-防火墙相关 2 ④-selinux相关 3 二.上传amp源代码包 5 三.linux下软件安装-vsftpd安装 6 ①-rpm ...
- [INSTALL_FAILED_OLDER_SDK]错误
在写完Demo后,执行时发现控制台打印出这么一段话:[INSTALL_FAILED_OLDER_SDK]错误. 原因是由于:測试机或者我们所用的虚拟机的android版本号太低. defaultCon ...
- MVC无限级分类01,分层架构,引入缓存,完成领域模型与视图模型的映射
本系列将使用zTree来创建.编辑关于品牌.车系.车型的无限级分类,使用datagrid显示,源码在github.先上最终效果: datagrid显示所有记录.分页,提供添加.修改.删除按钮,并提供简 ...