题目地址:http://vjudge.net/problem/UVALive-3602
第二次写,二周目
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<=(b);++i)
char A[50+1][1000+3],Ans[1000+3];
std::map<char, int> idx;
const char DNA[]="ACGT";
int main(int argc, char const *argv[])
{
int T; scanf("%d",&T);
idx['A']=0;idx['C']=1;idx['G']=2;idx['T']=3; //为了字典序
while(T--){
int n,m; char ch;
scanf("%d%d",&n,&m);
REP(i,1,n) scanf("%s",A[i]+1);
int cnt=0;
REP(j,1,m){
int B[4]={0};
REP(i,1,n) B[idx[A[i][j]]]++;
int sum=0,n=0;
REP(i,0,3) {
sum+=B[i];
if(n<B[i]) Ans[j]=DNA[i],n=B[i];
}
cnt+=sum-n;
}
Ans[m+1]='\0';
printf("%s\n%d\n", Ans+1,cnt);
}
return 0;
}