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

【题意】

在这里输入题意

【题解】

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

【代码】

#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. 设置select组件中的默认值

    会员卡类型   <select id="name2" style="width:140px"> <option value="Ak& ...

  2. C#运算符小例子

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  3. SSH远程快速登录Linux

    SSH远程快速登录Linux        使用SSH管理linux服务器,通常要使用ssh,然后输入用户,密码,其实只要配置一个文件就可以方便登录.假设要登录server域名是www.interne ...

  4. HDU 3594 The trouble of Xiaoqian 混合背包问题

    The trouble of Xiaoqian Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  5. groupmod---更改群组识别码或名称

    groupmod命令用于更改群组识别码或名称. 需要更改群组的识别码或名称时,可用groupmod指令来完成这项工作. 语法 groupmod [-g <群组识别码> <-o> ...

  6. cogs P1578【模板】 次小生成树初级练习题

    1578. 次小生成树初级练习题 ☆   输入文件:mst2.in   输出文件:mst2.out   简单对比时间限制:1 s   内存限制:256 MB [题目描述] 求严格次小生成树 [输入格式 ...

  7. CDN服务上线,DNSPOD布局云端生态圈

    爱因斯坦曾说过,我从不去想未来,由于它来得已经够快的了.是的,随着互联网的高速发展,我们的生活节奏越来越快,可是人们的耐心却像鞋底一样越磨越薄. 遥控器按一下,鼠标点一下,仅仅要认为没意思或者等待时间 ...

  8. PHP+FastCGI+Nginx动态请求处理配置

    Nginx不支持对外部程序的调用,所以必须通过FastCGI接口实现对外部程序的调用从而实现对client动态页面请求的处理. CGI的英文全称为Common Gateway Interface(公共 ...

  9. 10小时之内,暴力破解SSH账号的IP

    10小时之内,暴力破解SSH账号的IP,IP 地址数据来源于  ip138.com 182.18.76.246 北京市昌平区 北京亿安天下网络科技有限公司 联通 221.223.200.143 北京市 ...

  10. Spark通过YARN提交任务不成功(包含YARN cluster和YARN client)

    无论用YARN cluster和YARN client来跑,均会出现如下问题. [spark@master spark-1.6.1-bin-hadoop2.6]$ jps 2049 NameNode ...