【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

枚举每一位字母是什么。
从小到大枚举。
然后计算每一位的总贡献是多少。
取最小的那个输出。

【代码】

#include <bits/stdc++.h>
using namespace std; const int M = 50;
const int N = 1e3;
const char b[] = {'A','C','G','T'}; int T,n,m;
char s[M+10][N+100]; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "rt", stdin);
#endif
scanf("%d",&T);
while (T--){
scanf("%d%d",&n,&m);
for (int i = 1;i <= n;i++) scanf("%s",s[i]+1);
string ans1 = "";int ans2 = 0;
for (int j = 1;j <= m;j++){
int temp = 0x3f3f3f3f;char temp1;
for (int jj = 0;jj < 4;jj++){
char key = b[jj];
int cur = 0;
for (int i = 1;i <= n;i++){
cur += (s[i][j]!=key);
}
if (cur < temp){
temp1 = key;
temp = cur;
}
}
ans1+=temp1;ans2+=temp;
}
cout << ans1 <<endl;
cout << ans2 << endl;
} return 0;
}

【习题 3-7 UVA - 1368 】DNA Consensus String的更多相关文章

  1. uva 1368 DNA Consensus String

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

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

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

  3. UVa 3602 - DNA Consensus String 水题 难度: 0

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

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

  5. uva1368 DNA Consensus String

    <tex2html_verbatim_mark> Figure 1. DNA (Deoxyribonucleic Acid) is the molecule which contains ...

  6. DNA Consensus String

    题目(中英对照): DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It co ...

  7. 紫书第三章训练1 E - DNA Consensus String

    DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of ...

  8. DNA Consensus String UVA - 1368

    题目链接:https://vjudge.net/problem/UVA-1368 题意:给出一组字符串,求出一组串,使与其他不同的点的和最小 题解:这个题就是一个点一个点求,利用桶排序,求出最多点数目 ...

  9. uvalive 3602 DNA Consensus String

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

随机推荐

  1. UVA - 10032 Tug of War (二进制标记+01背包)

    Description Problem F: Tug of War A tug of war is to be arranged at the local office picnic. For the ...

  2. 蓝的成长记——追逐DBA(10):飞刀防身,熟络而非专长:摆弄中间件Websphere

    原创作品,出自 "深蓝的blog" 博客.欢迎转载,转载时请务必注明出处.否则追究版权法律责任. 深蓝的blog:http://blog.csdn.net/huangyanlong ...

  3. 75.《nodejs开发指南》express4.x版-微博案例完整实现

    转自:https://blog.csdn.net/cgwcgw_/article/details/39317587 完整代码下载 https://github.com/haishangfeie/wei ...

  4. Deep Networks : Overview

    Overview In the previous sections, you constructed a 3-layer neural network comprising an input, hid ...

  5. 深入了解"网上邻居"原理

    说到“网上邻居”,相信很多人都很熟悉.但是说起“网上邻居”的工作机制,可能大家就不太清楚了. 要说“网上邻居”的工作机制,不妨联系一下生活中的例子:比如我(A),要拜访一个远方的朋友(B),我要去他的 ...

  6. UVA - 10674-Tangents

     题意:给出两个圆,求它们的公切线,并依照一定格式输出 做法:模拟 代码: #include<iostream> #include<map> #include<str ...

  7. 9.使用 npm 命令安装模块

    转自:http://www.runoob.com/nodejs/nodejs-tutorial.html npm 安装 Node.js 模块语法格式如下: $ npm install <Modu ...

  8. 逐步配置企业版Symantec Norton防病毒服务器

    逐步配置企业版Symantec Norton防病毒服务器 配置企业版Symantec Norton NT操作系统,已经安装IIS 安装Symantec Norton 10 安装系统中心 650) th ...

  9. Python Unittest模块测试执行

    记录一下Unittest的测试执行相关的点 一.测试用例执行的几种方式 1.通过unittest.main()来执行测试用例的方式: if __name__ == "__main__&quo ...

  10. Scala中的“=>”和“<-”

    “=>”符号大概可以看做是创建函数实例的语法糖,例如 args.foreach(arg => println(arg)) 大概可以看做 args.foreach(Function(arg) ...