B. Ohana Cleans Up
 

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 test(s)
input
4
0101
1000
1111
0101
output
2
input
3
111
111
111
output
3
Note

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))的更多相关文章

  1. 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 ...

  2. 【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,输出任意方案. [算法]数学+搜索 [题解] 最关 ...

  3. 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 ...

  4. 【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))最 ...

  5. D. Zero Quantity Maximization ( Codeforces Round #544 (Div. 3) )

    题目链接 参考题解 题意: 给你 整形数组a 和 整形数组b ,要你c[i] = d * a[i] + b[i], 求  在c[i]=0的时候  相同的d的数量 最多能有几个. 思路: 1. 首先打开 ...

  6. 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 ...

  7. CodeForces 360E Levko and Game(Codeforces Round #210 (Div. 1))

    题意:有一些无向边m条权值是给定的k条权值在[l,r]区间可以由你来定,一个点s1 出发一个从s2出发  问s1 出发的能不能先打到f 思路:最短路. 首先检测能不能赢 在更新的时候  如果对于一条边 ...

  8. 贪心+构造( Codeforces Round #344 (Div. 2))

    题目:Report 题意:有两种操作: 1)t = 1,前r个数字按升序排列:   2)t = 2,前r个数字按降序排列: 求执行m次操作后的排列顺序. #include <iostream&g ...

  9. 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 ...

随机推荐

  1. [HDU5343]MZL's Circle Zhou

    题目大意: 给你两个字符串a和b,从中分别取出子串x和y,求不同的x+y的个数. 思路: 对于每一个字符串,构建SAM. 为了保证相同的x+y不会被重复统计,我们可以想办法只统计相同的x+y中x最长的 ...

  2. bzoj 3262

    题意:给你一些三维上的点,对于每个点,统计三个坐标都小于等于该点的点数. 如果点的范围在300以内,可以用三维树状数组搞,但这题坐标范围太大. 考虑将所有点按照x坐标排序,从左到右,相当于在一个二维平 ...

  3. android显示TextView文字的倒影效果

    今天记录一下TextView的倒影效果,显示一串文字,然后在文字的下方显示出它的倒影,先上效果图: 最重要的就是View中getDrawingCache()方法,该方法可以获取cache中的图像,然后 ...

  4. 洛谷P2746 USACO5.1 校园网

    题目描述 一些学校连入一个电脑网络.那些学校已订立了协议:每个学校都会给其它的一些学校分发软件(称作“接受学校”).注意即使 B 在 A 学校的分发列表中, A 也不一定在 B 学校的列表中. 你要写 ...

  5. URAL 1876 Centipede's Morning

    1876. Centipede's Morning Time limit: 0.5 secondMemory limit: 64 MB A centipede has 40 left feet and ...

  6. 证明 O(n/1+n/2+…+n/n)=O(nlogn)

    前言 在算法中,经常需要用到一种与调和级数有关的方法求解,在分析该方法的复杂度时,我们会经常得到\(O(\frac{n}{1}+\frac{n}{2}+\ldots+\frac{n}{n})\)的复杂 ...

  7. CodeForces 81D.Polycarp's Picture Gallery 乱搞

    D. Polycarp's Picture Gallery time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  8. ROS知识(6)----卸载ROS系统

    步骤方法: 1.首先卸载包 sudo apt-get purge ros-* 2.然后卸载依赖包 sudo apt-get autoremove

  9. linux下面mmap和setsignal函数用法

    #include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <fcntl.h& ...

  10. 再论C++之垃圾回收(GC)

    本文已经迁移到:http://cpp.winxgui.com/cn:garbage-collection-in-cplusplus 使用智能指针(smart pointers) http://www. ...