#include <iostream>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
int main()
{
int t;
cin >> t;
while (t-- > 0)
{
int m, n;//n为序列长度
cin >> m >> n;
string seqs[50];
string best;
int error = 0;
for (int i = 0; i < m; ++i)
{
cin >> seqs[i];
}
for (int j = 0; j < n; ++j)
{
map<char, int>nucleotide;//分别为ACGT数量
for (int i = 0; i < m; ++i)
{
++nucleotide[seqs[i][j]];
}
int biggest = 0;
char bestch;
map<char, int>::iterator iter;
for (iter = nucleotide.begin(); iter != nucleotide.end(); ++iter)
{
if (iter->second > biggest)
{
biggest = iter->second;
bestch = iter->first;
}
}
for (int i = 0; i < m; ++i)
{
if (bestch != seqs[i][j])
{
++error;
}
}
best += bestch;
}
cout << best << endl << error << endl;
}
}
DNA序列(DNA Consensus String, ACM/ICPC Seoul 2006, UVa1368
最新推荐文章于 2022-01-24 22:36:38 发布