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 ...
随机推荐
- Anroid 搭建Maven私服(Android Studio)
一.场景 ① 公司中有多个项目,多人开发,开发中的某一模块需要被其他几个项目的模块所依赖,最简单粗暴的方式就是打包成aar或者jar文件逐个拷贝到libs下进行依赖,可是这种方式太过于麻烦,而且需要每 ...
- 浅谈Nginx负载均衡与F5的区别
前言 笔者最近在负责某集团网站时,同时用到了Nginx与F5,如图所示,负载均衡器F5作为处理外界请求的第一道“墙”,将请求分发到web服务器后,web服务器上的Nginx再进行处理,静态内容直接访问 ...
- 《剑指offer》第五十二题(两个链表的第一个公共结点)
// 面试题52:两个链表的第一个公共结点 // 题目:输入两个链表,找出它们的第一个公共结点. #include <iostream> #include "List.h&quo ...
- 兼容低版本 ie 的思路
兼容处理 ie 低版本,推荐三条路径: 一.css hack,适用于代码初建阶段,也就是说在开发功能之前要思考的问题点,这里总结几个常见的: 1.- 区分 ie6 与 ie7以上 ( -text-in ...
- x1c2017 8G版 win linux的取舍纠结记录
x1c 2017 的 i5 7200U 8G ram 的丐版.换了1T SSD.其实一般使用没啥问题. 1 外出携带的轻便性太满意(mac13寸相比之下都太重了): 2 coding时候的安静性,比原 ...
- 第 8 章 容器网络 - 055 - 创建 macvlan 网络
1.创建 macvlan 网络 在 host1 和 host2 中创建 macvlan 网络 mac_net1: docker network create -d macvlan --subnet=1 ...
- boke练习: springboot整合springSecurity出现的问题,post,delete,put无法使用
springboot 与 SpringSecurity整合后,为了防御csrf攻击,只有GET|OPTIONS|HEAD|TRACE|CONNECTION可以通过. 其他方法请求时,需要有token ...
- 非常棒的——python Deep learning 学习笔记
https://www.cnblogs.com/zhhfan/p/9985991.html
- 终于可以从百度云上BOS读取数据到本地了
终于可以从百度云上BOS读取数据到本地了
- Merge K Sorted List(含Merge Two Sorted LIst) leetcode java
问题描述: Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complex ...