UVa 3602 - DNA Consensus String 水题 难度: 0

题目

https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1603

题意

问使m个n长碱基序列汉明码最小的序列

思路

明显,取最频繁的

代码

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#define LOCAL_DEBUG
using namespace std;
typedef pair<int, int> MyPair;
int cnt[][]; int main() {
#ifdef LOCAL_DEBUG
freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\input.txt", "r", stdin);
//freopen("C:\\Users\\Iris\\source\\repos\\ACM\\ACM\\output.txt", "w", stdout);
#endif // LOCAL_DEBUG
int T;
int m, n;
cin >> T;
for (int ti = ;cin>>m>>n; ti++) {
string tmp;
memset(cnt, , sizeof cnt);
for (int i = ; i < m; i++) {
cin >> tmp;
for (int j = ; j < n; j++) {
cnt[j][tmp[j]]++;
}
}
int ans = ;
for (int j = ; j < n; j++) {
char anschar = 'A';
for (char ch : {'A', 'C', 'G', 'T'}) {
if (cnt[j][ch] > cnt[j][anschar]) {
anschar = ch;
}
}
putchar(anschar);
ans += m - cnt[j][anschar];
}
putchar('\n');
printf("%d\n", ans);
} return ;
}
上一篇:Java中的三目运算符


下一篇:[手机取证] Apple Watch取证初探