#include <stdio.h>
char s[51][1001];
char compareA(int countA, int countC, int countG, int countT)
{
int temp = countT;
char c = 'T';
if(temp <= countG)
{
temp = countG;
c = 'G';
}
if(temp <= countC)
{
temp = countC;
c = 'C';
}
if(temp <= countA)
{
temp = countA;
c = 'A';
}
return c;
}
int main()
{
int num = 0;
int m, n;
scanf("%d", &num);
while(num--)
{
scanf("%d %d", &m, &n);
for(int i=0; i<m; i++)
{
scanf("%s",s[i]);
}
int countA=0, countC=0, countG=0, countT=0;
char temp;
int total = 0;
int all = 0;
for(int i = 0; i < n; i++)
{
countA=0, countC=0, countG=0, countT=0;
for(int j = 0; j < m; j++)
{
if(s[j][i] == 'A')
countA++;
else if(s[j][i] == 'C')
countC++;
else if(s[j][i] == 'G')
countG++;
else if(s[j][i] == 'T')
countT++;
}
temp = compareA(countA, countC, countG, countT);
total = countA + countC + countG + countT;
if(temp == 'A')
total -= countA;
else if(temp == 'C')
total -= countC;
else if(temp == 'G')
total -= countG;
else if(temp == 'T')
total -= countT;
all += total;
printf("%c", temp);
}
printf("\n");
printf("%d\n", all);
}
return 0;
}
UVa 1368 DNA Consensus String
最新推荐文章于 2023-12-02 15:58:17 发布