#include<stdio.h>
#include<string.h>
int m, n, l;
char s[55][1005];
char s2[1005];
int count[4];
int main(){
int t;
scanf("%d", &t);
while (t--){
scanf("%d%d", &m, &n);
for (int i = 0; i < m; i++){
scanf("%s", s[i]);
}
for (int j = 0; j < n; j++){
for (int i = 0; i < m; i++){
if (s[i][j] == 'A') count[0]++;
else if (s[i][j] == 'C') count[1]++;
else if (s[i][j] == 'G') count[2]++;
else if (s[i][j] == 'T') count[3]++;
}
if (count[0] >= count[1] && count[0] >= count[2] && count[0] >= count[3]){
s2[j] = 'A';
l += m - count[0];
}
else if (count[1] >= count[0] && count[1] >= count[2] && count[1] >= count[3]){
s2[j] = 'C';
l += m - count[1];
}
else if (count[2] >= count[0] && count[2] >= count[1] && count[2] >= count[3]){
s2[j] = 'G';
l += m - count[2];
}
else{
s2[j] = 'T';
l += m - count[3];
}
memset(count, 0, 4 * sizeof(int));
}
printf("%s\n%d\n", s2, l);
memset(s2, '\0', 1005 * sizeof(char));//特别注意要清零,wrong anwser坑在这
l = 0;
}
return 0;
}
Uva1368 - DNA Consensus String
最新推荐文章于 2022-01-24 22:36:38 发布