TOJ 2641 Gene
描述
How can millions of different and complex structures be built using only a few simple building blocks? Just ask your DNA. DNA (short for deoxyribonucleic acid) spells out the genetic codes of millions of species, using just four molecules: adenine (A), guanine (G), thymine (T), and cytosine (C). These molecules are called nucleotide bases. Different sequences of nucleotide bases are what define each species.
Within
this coil of DNA lies all the information needed to produce everything
in the human body. A strand of DNA may be millions, or billions, of
base-pairs long. Different segments of the DNA molecule code for
different characteristics in the body. A Gene is a relatively small
segment of DNA that codes for the synthesis of a specific protein. This
protein then will play a structural or functional role in the body. A
chromosome is a larger collection of DNA that contains many genes and
the support proteins needed to control these genes.
Now
, we give you the Sequence of some genes, which code for different
proteins. And then we give every protein a score.here comes your
problem,if we give you a chromosome in sequence , of course it can code
many proteins, can you arrange which proteins it code , with the object
to get The largest score (two proteins can not be overlap).
输入
There
will be several testcases. For each testcase, the first line is an
integer N(1 < N ≤ 100,000), the number of the genes we will give you.
Then followed N lines , each line contains a string S(the lenth of S is
no more than 10), the sequence of the gene , and an integer C, the
score of the protein the gene code. The last line of each testcase is a
string (the length of this string is no more than 1000), describes the
sequence of the chromosome.
输出
For each testcase , output the largest score in the sample’s format.
样例输入
4
AATG 3
AT 2
GCGG 3
GG 2
AATGCGG
3
A 1
C 1
G 1
T
样例输出
Case 1: 5
Case 2: 0
题目来源
dp[i+l]=max(dp[i]+M[temp]),M[temp]表示某基因的score值。
大量输入输出使用scanf。
#include <stdio.h>
#include <string>
#include <map>
#include <iostream>
using namespace std; int main(int argc, char *argv[])
{
int t,c=;
int dp[];
while(scanf("%d",&t)!=EOF){
char gene[];
int score;
map< string,int > M;
memset(dp,,sizeof(dp));
for(int i=; i<=t; i++){
scanf("%s %d",gene,&score);
M[gene]=score;
}
string g;
cin>>g;
int len=g.size();
for(int i=; i<len; i++){
for(int l=; l<=; l++){
if(l+i>len)continue;
string temp=g.substr(i,l);
if(dp[i+l] < dp[i]+M[temp]){
dp[i+l]=dp[i]+M[temp];
}
}
}
int ans=-;
for(int i=; i<=len; i++){
if(dp[i]>ans)
ans=dp[i];
}
printf("Case %d: %d\n",++c,ans);
}
return ;
}
TOJ 2641 Gene的更多相关文章
- TOJ 2776 CD Making
TOJ 2776题目链接http://acm.tju.edu.cn/toj/showp2776.html 这题其实就是考虑的周全性... 贡献了好几次WA, 后来想了半天才知道哪里有遗漏.最大的问题 ...
- KEGG and Gene Ontology Mapping in Bioinformatic Method
使用KOBAS进行KEGG pathway和Gene Ontology分析 Article from Blog of Alfred-Feng http://blog.sina.com.cn/u/170 ...
- 合并基因表达水平(merge gene expression levels, FPKM)
使用tophat和cufflinks计算RNA-seq数据的表达水平时,当一个基因在一个样本中有多个表达水平时需要合并它们的表达水平. This code is a solution to colla ...
- augustus, gene prediction, trainning
做基因组注释 先用augustus训练,然后再用maker做基因注释 augustus提供一些训练好的,如果有和你的物种非常接近的,直接用提供的,没有的话再自己训练. 网址: http://bioin ...
- gene框架文档 - 路由类 gene_router
路由类 Gene\Router 介绍 Gene\Router 是gene框架的核心类之一,本框架区别于其他常见框架的最大地方就是独特.强大.简单的路由定义等.路由强大灵活,支持回调.类方法:支持res ...
- gene框架文档 - 概述
欢迎使用Gene框架 最新版本:V1.2.2 开源地址:https://github.com/sasou/php-gene 作者:sasou 文档地址:http://php-gene.com/doc ...
- Human Gene Functions
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 1004 ...
- POJ 1080 Human Gene Functions -- 动态规划(最长公共子序列)
题目地址:http://poj.org/problem?id=1080 Description It is well known that a human gene can be considered ...
- poj1080--Human Gene Functions(dp:LCS变形)
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17206 Accepted: ...
随机推荐
- Django-项目上线后,静态文件配置失效以及404、500页面的全局配置
https://blog.csdn.net/Jamin2018/article/details/79060509 https://www.cnblogs.com/lfoder/p/6013142.ht ...
- Spring中的用到的设计模式
应该说设计模式是我们在写代码时候的一种被承认的较好的模式.好的设计模式就像是给代码造了一个很好的骨架,在这个骨架里,你可以知道心在哪里,肺在哪里,因为大多数人都认识这样的骨架,就有了很好的传播性.这是 ...
- 微信 oauth2 两次回调
场景: logger.Info("f: " + wx.From); logger.Info("c: " + wx.Code); logger.Info(&quo ...
- day08.1-Linux软件包管理
Linux系统中的两种软件包:tar,保存内容为源码,编译后再安装:rpm,保存内容为编译后的机器码,直接安装.其中,rpm软件包由5部分构成,分别为: 第1部分是name,表示这个rpm软件包的名称 ...
- Django的文件上传以及预览、存储
思路: 文件上传通过前端的input标签,input设置display:none属性. 内容显示需要让前端通过<img>标签读取图片内容,可以通过<label>标签连接< ...
- [Swift]八大排序算法(二):快速排序
排序分为内部排序和外部排序. 内部排序:是指待排序列完全存放在内存中所进行的排序过程,适合不太大的元素序列. 外部排序:指的是大文件的排序,即待排序的记录存储在外存储器上,待排序的文件无法一次装入内存 ...
- linux防火墙(二)—— iptables语法之选项和控制类型
一.语法: iptables [-t 表名] 选项 [链名] [匹配条件] [-j 控制类型] 未指定表名时,默认用filter表:链名,控制类型要大写:除非设置默认策略,否则必须指定匹配条件:不指定 ...
- application的使用(实现计数器)
application在整个WEB项目中共享使用数据. 常用方法: getAttribute(); setAttribute();示列: <% Object count=applicati ...
- 在Discuz X 中增加一个单独的页面
如果在DZ中增加一个新的页面,并且取得DZ中相关的用户等乱七八糟的属性,在旧的版本中只要引用一个 -. comm.php 文件就可以,但是在 X 版本以后好像就没.还好,X版本中还是有办法解决的,使用 ...
- SQL Server为啥使用了这么多内存?
原文地址:http://support.microsoft.com/gp/anxin_techtip6/zh-cn SQL Server为啥使用了这么多内存? SQL Server的用户,常常会发现S ...