# 习题3-7(uva-1368)

#include <iostream>
#include <vector>
#include <stack>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cmath>
#include <cctype>
#include <string>
#include <cstdio>
#include <iomanip>

#include <mutex>
#include <condition_variable>
#include <functional>
#include <iterator>
using namespace std;
int r, c;
int matrix[1005][4] = { 0 };
char input[1005];

int GetIndex(char in) {
switch (in)
{
case 'A':return 0;
case 'C':return 1;
case 'G':return 2;
case 'T':return 3;
default:
break;
}
return -1;
}
char GetChar(int id) {
switch (id)
{
case 0:return 'A';
case 1:return 'C';
case 2:return 'G';
case 3:return 'T';
default:
break;
}
return 'Z';
}
void CulCount() {
int  temp = 0;
for (int i = 0; i < c; ++i) {
temp = GetIndex(input[i]);
for (int j = 0; j < 4; ++j) {
if(temp == j) continue;
matrix[i][j]++;
}
}
}
int main()
{
int t,id;
cin >> t;
while (t--) {
int nCount = 0;
memset(matrix, 0, sizeof(matrix));
cin >> r >> c;
cin.get();
for (int i = 0; i < r; ++i) {
fgets(input, 1005, stdin);
CulCount();
}

for (int i = 0; i < c; ++i) {
id = 0;
for (int j = 1; j < 4; ++j) {
if (matrix[i][j] < matrix[i][id]) id = j;
}
nCount += matrix[i][id];
input[i] = GetChar(id);
}
input[c] = '\0';
cout << input << endl;
cout << nCount << endl;
}
return 0;
}

• 点赞
• 评论
• 分享
x

海报分享

扫一扫，分享海报

• 收藏
• 打赏

打赏

小刀刺大熊

你的鼓励将是我创作的最大动力

C币 余额
2C币 4C币 6C币 10C币 20C币 50C币
• 举报
• 一键三连

点赞Mark关注该博主, 随时了解TA的最新博文
11-08 21

03-25 52
09-30 150
03-19 34
03-25 39
10-29 19