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 ;
}
UVa 3602 - DNA Consensus String 水题 难度: 0的更多相关文章
- UVa 10340 - All in All 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa LA 3213 - Ancient Cipher 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 贪心水题。UVA 11636 Hello World,LA 3602 DNA Consensus String,UVA 10970 Big Chocolate,UVA 10340 All in All,UVA 11039 Building Designing
UVA 11636 Hello World 二的幂答案就是二进制长度减1,不是二的幂答案就是是二进制长度. #include<cstdio> int main() { ; ){ ; ) r ...
- UVa 10970 - Big Chocolate 水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- 【每日一题】UVA - 1368 DNA Consensus String 字符串+贪心+阅读题
https://cn.vjudge.net/problem/UVA-1368 二维的hamming距离算法: For binary strings a and b the Hamming distan ...
- uva 1368 DNA Consensus String
这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每 ...
- uvalive 3602 DNA Consensus String
https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序 ...
- UVa 11039 - Building designing 贪心,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
- UVa 11636 - Hello World! 二分,水题 难度: 0
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...
随机推荐
- 力扣(LeetCode)461. 汉明距离
两个整数之间的汉明距离指的是这两个数字对应二进制位不同的位置的数目. 给出两个整数 x 和 y,计算它们之间的汉明距离. 注意: 0 ≤ x, y < 231. 示例: 输入: x = 1, y ...
- 学习笔记28—Python 不同数据类型取值方法
1.array数据类型 1)-------> y[i,] 或者 y[i] 2.遍历目录下所有文件夹: def eachFile(filepath): pathDir = os.list ...
- AD绘制PCB时,贴片封装器件的焊盘间距小于10Mil,报错解决
Design->Rules->Manufacturing->Minimum Solder Mask Sliver
- 第 8 章 容器网络 - 061 - flannel 的连通与隔离
flannel 的连通与隔离 测试 bbox1 和 bbxo2 的连通性: bbox1 能够 ping 到位于不同 subnet 的 bbox2,通过 traceroute 分析一下 bbox1 到 ...
- 第 3 章 镜像 - 015 - 调试 Dockerfile
如何 debug Dockerfile 通过 Dockerfile 构建镜像的过程 从 base 镜像运行一个容器 执行命令对容器做修改 执行类似 docker commit 的操作,生成一个新的镜像 ...
- CRC分段校验
crc16 modbus分段校验码: const uint8_t ModbusCRCHighTab[] = { 0x00, 0xC1, 0x81, 0x40, 0x01, 0xC0, 0x80, 0x ...
- makefile 里的vpath
https://www.cmcrossroads.com/article/basics-vpath-and-vpath Only missing prerequisites matching the ...
- php解析处理java的btye字节;php解析处理java的ByteArrayOutputStream字节流/数据流
php解析处理java的btye字节:php解析处理java的ByteArrayOutputStream字节流/数据流 一般java的字节流: 就是t public class Test { publ ...
- sgu 139 Help Needed!
题意:16数码是否有解? 先计算展开成一维后逆序对.如果0在最后一行,那么逆序偶时有解.4*4时(n为偶)0的位置上升一行,逆序对+3或-1(奇偶性变化).(n为奇时+2或+0,不变) #includ ...
- java.——最大子序列和(前提是:全部都是非负数)
直接上代码吧: 情况一:全部是非负数整数的时候,其实非负实数处理也一样. package Person; import java.util.Scanner; public class Main{ ...