谁来帮帮孩子55
查看原帖
谁来帮帮孩子55
340169
x1211270017楼主2020/8/12 01:48
#include <stdio.h>

int main()
{
    int T;
    scanf("%d",&T);
    for(int i=0;i<T;i++)
    {
        int m,n;
        scanf("%d%d\n",&m,&n);
        char str[55][1010],con_str[1010];int correct[1010]={};
        for(int j=0;j<m;j++) scanf("%s",str[j]);
        for(int j=0;j<n;j++)
        {
            int count[26]={},max=0;
            for(int k=0;k<m;k++)
            {
                count[str[k][j]-'A']++;
            }
            for(int k=0;k<26;k++)
            {
                if(count[k]>max)
                {
                    max=count[k];
                    con_str[j]=k+'A';
                    correct[j]=count[k];
                }
            }
        }
        int error=m*n;
        for(int j=0;j<n;j++) error-=correct[j];
        printf("%s\n%d\n",con_str,error);
    }
}
2020/8/12 01:48
加载中...