DNA Consensus String UVA - 1368
题目链接:https://vjudge.net/problem/UVA-1368
题意:给出一组字符串,求出一组串,使与其他不同的点的和最小
题解:这个题就是一个点一个点求,利用桶排序,求出最多点数目的集合,如果点数相同,则按字母序最小的点为准
ac代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char ch[60][1100],ans[1100];
int main()
{
int n,x,y,j;
cin>>n;
while(n--)
{
int sum=0;
cin>>x>>y;
getchar();//吸收空行
for(int i=1; i<=x; i++)
scanf("%s",ch[i]);
for(j=0; j<y; j++)
{
int maxn=0;
int zi[30];
memset(zi,0,sizeof(zi));
for(int i=1; i<=x; i++)
zi[ch[i][j]-'A']++;
for(int i=0; i<26; i++)
if(zi[i]>maxn)
maxn=zi[i];
for(int i=0; i<26; i++)
if(zi[i]==maxn)
{
ans[j]=i+'A';
break;
}
}
ans[j]=0;
for(int i=1;i<=x;i++)
{
for(int j=0;j<y;j++)
if(ch[i][j]!=ans[j]) sum++;
}
cout<<ans<<endl;
cout<<sum<<endl;
}
return 0;
}
DNA Consensus String UVA - 1368的更多相关文章
- 贪心水题。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 ...
- uva1368 DNA Consensus String
<tex2html_verbatim_mark> Figure 1. DNA (Deoxyribonucleic Acid) is the molecule which contains ...
- DNA Consensus String
题目(中英对照): DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It co ...
- 紫书第三章训练1 E - DNA Consensus String
DNA (Deoxyribonucleic Acid) is the molecule which contains the genetic instructions. It consists of ...
- uva 1368 DNA Consensus String
这道题挺简单的,刚开始理解错误,以为是从已有的字符串里面求最短的距离,后面才发现是求一个到所有字符串最小距离的字符串,因为这样的字符串可能有多个,所以最后取最小字典序的字符串. 我的思路就是求每一列每 ...
- 【每日一题】UVA - 1368 DNA Consensus String 字符串+贪心+阅读题
https://cn.vjudge.net/problem/UVA-1368 二维的hamming距离算法: For binary strings a and b the Hamming distan ...
- 【习题 3-7 UVA - 1368 】DNA Consensus String
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 枚举每一位字母是什么. 从小到大枚举. 然后计算每一位的总贡献是多少. 取最小的那个输出. [代码] #include <bi ...
- UVa 3602 - DNA Consensus String 水题 难度: 0
题目 https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- uvalive 3602 DNA Consensus String
https://vjudge.net/problem/UVALive-3602 题意: 给定m个长度均为n的DNA序列,求一个DNA序列,使得它到所有的DNA序列的汉明距离最短,若有多个解则输出字典序 ...
随机推荐
- Flask01-HelloWorld
# flask学习 参考:http://www.pythondoc.com/flask-mega-tutorial/ ## python3. 默认支持虚拟环境使用(用最简单的方法,解决问题) wget ...
- SpringBoot--整合Lettuce redis
首先解释一下Lettuce客户端: Lettuce 和 Jedis 的都是连接Redis Server的客户端程序.Jedis在实现上是直连redis server,多线程环境下非线程安全,除非使用连 ...
- MongoDB快速入门教程 (4.2)
4.2.Mongoose实现增删查改 中文文档地址: https://cn.mongoosedoc.top/docs/guide.html 4.2.1.Mongoose是什么? Mongoose是Mo ...
- 全栈的自我修养: 001环境搭建 (使用Vue,Spring Boot,Flask,Django 完成Vue前后端分离开发)
全栈的自我修养: 环境搭建 Not all those who wander are lost. 彷徨者并非都迷失方向. Table of Contents @ 目录 前言 环境准备 nodejs v ...
- 报错 500 - Request processing failed; nested exception is com.alibaba.dubbo.rpc.RpcException的解决放案
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/loveliness_peri/artic ...
- hive中如何查询除了其中某个字段剩余所有字段
想要将hive分区表中的某个分区复制到新的分区中,使用如下sql语句 insert overwrite table zcfw_sda.sda04_core_request_base_ratio_ifr ...
- node-koa
什么是koa 基于node.js 平台的下一代web开发框架 async await npm install --save koa npm install --save koa-router ctx. ...
- 5年前端经验小伙伴教你纯css3实现饼状图
有一些网页中,有时候会碰到饼状图的需求,比如统计图表,进度指示器,定时器等,实现方式也是各种各样,现在也有不少现成的js库,可以直接拿来使用,方便很多.这里笔者为大家演示一种纯css实现饼状图效果的方 ...
- SCOI 2009 围豆豆(状压DP)
SCOI 2009 围豆豆 题目描述 是不是平时在手机里玩吃豆豆游戏玩腻了呢?最近MOKIA手机上推出了一种新的围豆豆游戏,大家一起来试一试吧. 游戏的规则非常简单,在一个N×M的矩阵方格内分布着D颗 ...
- CF833A The Meaningless Game 题解
题目 Slastyona and her loyal dog Pushok are playing a meaningless game that is indeed very interesting ...