题目

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. 学习笔记4-pathon的range()函数和list()函数

    使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的slide,最后分析一个好玩儿的冒泡程序. 这里记 ...

  2. 将本地项目上传到gitlab下

    转载自: https://blog.csdn.net/litianxiang_kaola/article/details/74075151 1.安装git    https://git-scm.com ...

  3. Codeforces 797C - Minimal string

    C. Minimal string 题目链接:http://codeforces.com/problemset/problem/797/C time limit per test 1 second m ...

  4. UCS2编码

    UCS2就是标准的unicode编码, 它是某国际组织设计的一种文字符号编码表,包括了世界上绝大多数文字和符号,包括中文,每个字符使用2字节编码,因此叫ucs2. 这里有一篇文章对Unicode编码做 ...

  5. 20180831xlVBA_WorksheetsCosolidate

    Sub WorkSheetsConsolidate() Rem 设置求和区域为 单元格区域;单元格区域 Const Setting As String = "A1;B2:C4" D ...

  6. 维护满足max(+ or -)min<=k的区间

    这是一种经典的单调栈+线段树的维护方法. 从左到右枚举右端点. 线段树维护每一个左端点的max(+ or -)min的值. 每次右端点移动的时候,把a[i]加入单调栈. 每弹栈一次,便在线段树上把对应 ...

  7. CF1114E Arithmetic Progression

    给定一个打乱的等差数列,每次两种操作. 1.查询一个位置. 2.查询是否有比x大的数字. 一共60次操作. sol: 30次操作即可二分出首项. 剩下30次操作查询出30个位置然后两两做差取gcd即可 ...

  8. Django中模型层中ORM的多表操作

    ORM的多表创建(一对一.一对多,多对多): 1模型创建 实例:我们来假定下面这些概念,字段和关系 作者模型:一个作者有姓名和年龄. 作者详细模型:把作者的详情放到详情表,包含生日,手机号,家庭住址等 ...

  9. 384. Shuffle an Array(java,数组全排列,然后随机取)

    题目: Shuffle a set of numbers without duplicates. 分析: 对一组不包含重复元素的数组进行随机重排,reset方法返回最原始的数组,shuffle方法随机 ...

  10. MySQL 8.0窗口函数

    团队介绍 网易乐得DBA组,负责网易乐得电商.网易邮箱.网易技术部数据库日常运维,负责数据库私有云平台的开发和维护,负责数据库及数据库中间件Cetus的开发和测试等等. 一.窗口函数的使用场景 作为I ...