Codeforces 554B. Ohana Cleans Up

output

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.

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.

其实就是找有几个相同的字符串。。

#include<iostream>
#include<cstring>
#include<cstdio>
#include <string>
#include <sstream>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
#define MOD 1000000007
string s;
int n;
map<string,int> m;
int main(){
  // freopen("test.in","r",stdin);
  cin >> n;
  for (int i=1;i<=n;i++){
    cin >> s;
    m[s] ++;
  }
  int res(0);
  for (auto it=m.begin();it!= m.end();it++){
    res = max((*it).second,res);
  }
  cout << res;
  return 0;
}

时间: 2024-11-08 09:20:20

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 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 swe

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 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 swe

贪心 Codeforces Round #309 (Div. 2) B. Ohana Cleans Up

题目传送门 1 /* 2 题意:某几列的数字翻转,使得某些行全为1,求出最多能有几行 3 想了好久都没有思路,看了代码才知道不用蠢办法,匹配初始相同的行最多能有几对就好了,不必翻转 4 */ 5 #include <cstdio> 6 #include <algorithm> 7 #include <string> 8 #include <cmath> 9 #include <iostream> 10 using namespace std; 1

CodeForces 554B()

  CodeForces 554B Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u 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 Cleans Up

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: i

Codeforces554B: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 sq

B. Ohana Cleans Up

题目链接:http://codeforces.com/problemset/problem/554/B 题目大意: 奥哈马清理一间被分成n*n格的房间,每格使用数字‘1’和‘0’来表示状态,单格用1表示,则表明是干净的,用0表示则是脏的.清理时,奥哈马只能一整列的打扫,而且被打扫的单格如果是干净(1)的就会变脏(0),而如果是脏(0)的就会变干净(1).清理的列数不定,问他清理后最多有多少行能完全干净? 案例: Input 4 0101 1000 1111 0101 Output 2 Input

Ohana Cleans Up0101

题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=187195 题意: 一组数据只有0和1,0表示地板是脏的,1表示地板是干净的,现在,拖地板只能一列一列的拖,被拖的0会变为1,1会变为0,需找出最多可以有多少行地板是完全干净的. (可以不拖地板) 案例: 1)input 4 0101 1000 1111            0101           output 2 2) input 3 1 1 1 1

#309 (div.2) B. Ohana Cleans Up

1.题目描述:点击打开链接 2.解题思路:本题是一道简单的找最大值问题.只需要找出完全相同的行中个数那一行即可,输出它的个数.由于给定的范围比较小,可以直接用O(N^3)的算法解决.查找的时候用一个mark数组来标记哪些行已经查找过了,这样可以避免重复查找. 3.代码: #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<algorithm> #include<string> #include<s