CodeForces-554B Ohana Cleans Up

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int maxn = 100 + 5;
char room[maxn][maxn];
int num[maxn];
int cnt[maxn];
int n;

int main()
{
    while(~scanf("%d", & n))
    {
        memset(cnt, 0, sizeof(cnt));
        for(int i = 0; i < n; i ++)
            scanf("%s", room[i]);
        for(int k = 0; k < n; k ++)
        {
            for(int i = 0; i < n; i ++)
            {
                bool flag = true;
                for(int j = 0; j < n; j ++)
                    if(room[k][j] == room[i][j])
                        continue;
                    else
                    {
                        flag = false;
                        break;
                    }
                if(flag)
                    cnt[k] ++;
            }
        }
        sort(cnt, cnt + n);
        printf("%d\n", cnt[n - 1]);
    }
    return 0;
}

题意:输入n。之后输入n×n的01矩阵。就是翻列。问最后可以有多少行全是1.

题解:其实质就是找行最多相同的数量。三个for循环直接搞定...然而我还是瞎比搞半天。比较两行,看是否相同,相同cnt[k] ++。最后输出最大的cnt即是结果。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值