codeforces 554B Ohana Cleans Up
2015-07-17 15:44
447 查看
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 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.
0101
1000
1111
0101
111
111
111
In the second sample, everything is already clean, so Ohana doesn’t need to do anything.
实现代码
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
40101
1000
1111
0101
output
2input
3111
111
111
output
3Note
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.
实现代码
#include<iostream> #include<cstring> #include<algorithm> using namespace std; int const Max=110; char room[Max][Max]; int main() { int n,sum=0,t=0; cin>>n; for(int i=0;i<n;i++) cin>>room[i]; for(int i=0;i<n;i++) { sum=0; for(int j=0;j<n;j++) { if(!(strcmp(room[i],room[j]))) sum++; } t=max(sum,t); } cout<<t<<endl; return 0; }
相关文章推荐
- Integer Partition(hdu4658)2013 Multi-University Training Contest 6 整数拆分二
- 基于 REST 的 Web 服务:基础
- Service完全解析(转)
- easy_install安装第三方包出现的问题
- 关于死锁
- PHP语言的十二种特性
- LoadrRunner报错-Error: The table 'F:\测试脚本\loadrunner\toutTest3\NewParam.dat' does not exist.
- git hub使用秘籍
- 开灯问题
- 用GDB调试程序(七)
- MySql数据库SQL入门
- 教程-Delphi7 自带控件安装对应表
- HDU 3033 分组背包变形(每种至少一个)
- iOS- 友盟社会化分享-如何设置title
- (转)CTP: 平昨仓与平今仓,log轻轻告诉你.......
- PHPCMS动态调用导航菜单
- java导入导出Excel poi跟jxl
- iOS项目的目录结构和开发流程
- 图片旋转90度解决办法
- bsh规则调用(bsh-1.3.0.jar),相当于javascript里面的eval