You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.3 KiB

#include <bits/stdc++.h>
using namespace std;
int main() {
int time;
scanf("%d", &time);
while (time--) {
int m, n;
scanf("%d%d\n", &m, &n);
char dna[m][n + 2];
char out[n];
int i, j;
for (i = 0; i < m; i++)
scanf("%s", dna[i]);
int sum = 0;
for (j = 0; j < n; j++) {
int A = 0, C = 0, G = 0, T = 0, max = 0;
for (i = 0; i < m; i++) {
if (!(dna[i][j] - 'A'))
A++;
else if (!(dna[i][j] - 'G'))
G++;
else if (!(dna[i][j] - 'C'))
C++;
else if (!(dna[i][j] - 'T'))
T++;
}
if (max < A)
max = A;
if (max < C)
max = C;
if (max < G)
max = G;
if (max < T)
max = T;
if (max == A)
out[j] = 'A';
else if (max == C)
out[j] = 'C';
else if (max == G)
out[j] = 'G';
else if (max == T)
out[j] = 'T';
printf("%c", out[j]);
sum += max;
}
printf("\n%d\n", m * n - sum);
}
return 0;
}