-
Notifications
You must be signed in to change notification settings - Fork 1
/
uva1368.cpp
38 lines (35 loc) · 895 Bytes
/
uva1368.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <cstring>
const int M = 60, N = 1000;
char a[M][N];
char res[N];
int m, n;
char dna[4] = {'A', 'C', 'G', 'T'};
int index(char ch) {
for(int i = 0; i < 4; i++)
if(ch == dna[i]) return i;
return -1;
}
int main() {
int T; scanf("%d", &T);
while(T--) {
scanf("%d%d", &m, &n);
int map[4];
for(int i = 0; i < m; i++) scanf("%s", a[i]);
memset(res, 0, sizeof res);
int dist = 0;
for(int j = 0; j < n; j++) {
memset(map, 0, sizeof map);
for(int i = 0; i < m; i++) {
map[index(a[i][j])]++;
}
int maxi = 0;
for(int i = 0; i < 4; i++)
if(map[i] > map[maxi]) maxi = i;
res[j] = dna[maxi];
dist += m -map[maxi];
}
printf("%s\n%d\n", res, dist);
}
return 0;
}