CF 554B 找相同行

给定一个由n*n块地砖铺成的房间,每块砖用0表示未打扫,1表示已打扫。
要求打扫时只能整列地扫,未打扫的会变为已打扫,已打扫的会变为未打扫。
即1会变成0,而0会变成1,
目标是 使最后整行为1的行数最大
输出打扫后 最多有几行边为1

比如样例1 对1 ,3列 打扫 则1,4行能变为全1

所以 就是看有几个相同的行就可以了

input
4
0101
1000
1111
0101

3
111
111
111
output
2

3

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <algorithm>
 5 # include <cmath>
 6 # define LL long long
 7 using namespace std ;
 8 
 9 int main ()
10 {
11     //freopen("in.txt","r",stdin) ;
12     char a[110][110] ;
13     int n ;
14     while(scanf("%d" , &n) != EOF)
15     {
16         int i , j;
17         for (i = 0 ; i < n ; i++)
18            scanf("%s" , a[i]) ;
19         int ans = 0 ;
20         for (i = 0 ; i < n ; i++)
21         {
22             int t = 0 ;
23             for (j = 0 ; j < n ; j++)
24             {
25                 if (strcmp(a[i] , a[j]) == 0)
26                     t++ ;
27             }
28             ans = max(ans , t) ;
29         }
30         printf("%d
" , ans) ;
31     }
32 
33     return 0 ;
34 }
View Code
原文地址:https://www.cnblogs.com/mengchunchen/p/4657050.html