枚举每一列的位置,求哪个字符出现的次数最多
#include<iostream> #include<string> #include<map> #include<cstdio> #include<vector> #include<algorithm> #include<assert.h> #include<cstring> using namespace std; #define _for(i, a, b) for (int i = (a); i < (b); ++i) #define _rep(i, a, b) for (int i = (a); i <= (b); ++i) char s[60][1050]; map<int, char> mp; int main(){ mp[0] = 'A'; mp[1] = 'C'; mp[2] = 'G'; mp[3] = 'T'; int T; cin >> T; while(T--){ int n, m,cnt=0; cin >> n >> m; _for(i,0,n){ scanf("%s", s[i]); } string ans = ""; _for(i,0,m){ int a[4] = {0}; _for(j,0,n){ switch(s[j][i]){ case 'A': a[0]++; break; case 'C': a[1]++; break; case 'G': a[2]++; break; case 'T': a[3]++; break; } } int index = 0, num = a[0]; _for(i, 1, 4) { if (a[i] > num) { num = a[i]; index = i; } } cnt += (n - num); ans.append(1, mp[index]); } cout << ans << endl; cout << cnt << endl; } return 0; }相关文章
- 03-24uva 1368 水题
- 03-24Codeforces Round #352 (Div. 2) B. Different is Good 水题
- 03-24A. Sum of Odd Integers(水题)
- 03-24poj 3589(水题)
- 03-24五一训练包 水题
- 03-24Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题
- 03-24HDU 5327 Olympiad (水题)
- 03-24A. Expression【1000 / 水题】
- 03-24装箱问题(NOIP2001&水题测试2017082401)
- 03-24ZOJ 1586 QS Network MST prim水题