题目

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的更多相关文章

  1. UVa 10340 - All in All 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  2. UVa LA 3213 - Ancient Cipher 水题 难度: 0

    题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  3. 贪心水题。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 ...

  4. UVa 10970 - Big Chocolate 水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  5. 【每日一题】UVA - 1368 DNA Consensus String 字符串+贪心+阅读题

    https://cn.vjudge.net/problem/UVA-1368 二维的hamming距离算法: For binary strings a and b the Hamming distan ...

  6. uva 1368 DNA Consensus String

    这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每 ...

  7. uvalive 3602 DNA Consensus String

    https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序 ...

  8. UVa 11039 - Building designing 贪心,水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

  9. UVa 11636 - Hello World! 二分,水题 难度: 0

    题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&a ...

随机推荐

  1. 使用Hexo搭建一个简单的博客(二)

    昨天想着用Hexo和github搭一个自己简单的博客,记录一下自己踩过的坑,具体的流程就不重复了,主要参考了一下几篇文章 GitHub+Hexo 搭建个人网站详细教程 使用Hexo+Github一步步 ...

  2. 虹软2.0免费离线人脸识别 Demo [C++]

    环境: win10(10.0.16299.0)+ VS2017 sdk版本:ArcFace v2.0 OPENCV3.43版本 x64平台Debug.Release配置都已通过编译 下载地址:http ...

  3. jS冒泡优化

    <script>    //冒泡优化    将一个数组中的值从小到大排列    var arr=[65,85,12,36,75,46,50];    var sorted=true;   ...

  4. css设置字体单行,多行超出省略号显示

    单行: overflow: hidden; text-overflow:ellipsis; white-space: nowrap; 多行 display: -webkit-box; -webkit- ...

  5. flex属性的学习

    1.需要记住的属性和值. ------------------------------------------------------------- 方向横和纵 flex-direction: row ...

  6. js时间戳如何转时间

    js时间戳如何转时间 一.总结 一句话总结:Date对象分别获取年now.getFullYear()月now.getMonth()+1日now.getDate()即可 Date对象分别获取年now.g ...

  7. boke练习: spring boot: security post数据时,要么关闭crst,要么添加隐藏域

    spring boot: security post数据时,要么关闭crst,要么添加隐藏域 http.csrf().disable(); 或者: <input name="${_cs ...

  8. Java类成员变量的默认值

    1.布尔型(boolean)变量默认值为false,byte.short.int.long为0,字符型为'\u0000'(空字符),浮点型(float double)为0.0,引用类型(String) ...

  9. 文件上传MultipartBody使用方法

    最近有使用一个文件上传的功能,需要在请求中添加文件,一起传给服务器 Okhttp提供了这个文件添加然后上传的功能 下面给出核心的代码,然后分析一下 //多个文件上传,Filelist private ...

  10. android -------- Data Binding的使用(一)

    Google推出自己官方的数据绑定框架Data Binding Library 已经很久了,很多企业也在使用 面试的时候也有问到,所以也去学习了一番,特来分享一下,希望对各位有所帮助 描述: Data ...