poj 1080 Human Gene Functions(dp)】的更多相关文章

题目:http://poj.org/problem?id=1080 题意:比较两个基因序列,测定它们的相似度,将两个基因排成直线,如果需要的话插入空格,使基因的长度相等,然后根据那个表格计算出相似度. 题解: 考虑f[i][j]: ①    s1取第i个,s2取第j个, f[i][j] = f[i-1][j-1]+value[m(s1[i])][m(s2[j])]; ②    s1取第i个,s2用’-’, f[i][j] = f[i][j-1]+value[m(s1[i])][m(‘-’)];…
Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17805   Accepted: 9917 Description It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four…
Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19573   Accepted: 10919 Description It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four…
题目地址:http://poj.org/problem?id=1080 Description It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifyi…
题目链接: http://poj.org/problem?id=1080 题目大意: 给两个由A.C.T.G四个字符组成的字符串,可以在两串中加入-,使得两串长度相等. 每两个字符匹配时都有个值,求怎样安排使得总的值最大,两个-不能匹配. 解题思路: 这题转化一下就是一个裸的最长公共子串问题,只不过要求匹配时长度一样. dp[i][j]表示第一串的第前i个字符和第二串的前j个字符匹配时,能达到的最大值. 初始化时注意dp[0][j]和dp[j][0]不能为零,为相应字符与-匹配时的总和. 代码:…
题目大意:每次给出两个碱基序列(包含ATGC的两个字符串),其中每一个碱基与另一串中碱基如果配对或者与空串对应会有一个分数(可能为负),找出一种方式使得两个序列配对的分数最大 思路:字符串动态规划的经典题,很容易想到状态dp[i][j],指第一个长度为i的串和第二个长度为j的串配对的最大分数.显然,这个状态可以由dp[i][j-1],dp[i-1][j],dp[i-1][j-1]三个子问题得到,即第一串最后一个字符对应空格.第二串最后一个字符对应空格和第一串第二串最后一个字符配对所得到的分数这三…
题意:给两个DNA序列,在这两个DNA序列中插入若干个'-',使两段序列长度相等,对应位置的两个符号的得分规则给出,求最高得分. 解法:dp.dp[i][j]表示第一个字符串s1的前i个字符和第二个字符串s2的前j个字符对齐时的最高得分,转移方程:dp[i][j] = max{dp[i - 1][j - 1] + a[s1[i]][s2[j]], dp[i - 1] + a[s1[i]]['-'] + dp[i][j - 1] + a['-'][s2[j]]},第一项表示对齐时s1[i]和s2[…
题意:有两个代表基因序列的字符串s1和s2,在两个基因序列中通过添加"-"来使得两个序列等长:其中每对基因匹配时会形成题中图片所示匹配值,求所能得到的总的最大匹配值. 题解:这题运用dp的解法是借用了求最长公共子序列的方法,,定义dp[i][j]代表s1以第i位结尾的串和s2以第j位结尾的串匹配时所能得到的最大匹配值:那么状态转移方程为:dp[i][j]=max( dp[i-1][j-1]+s1[i]和s2[j]的匹配值 , dp[i-1][j]+s1[i]和'-'的匹配值 , dp[…
题面 It is well known that a human gene can be considered as a sequence, consisting of four nucleotides, which are simply denoted by four letters, A, C, G, and T. Biologists have been interested in identifying human genes and determining their function…
题意: 人类基因由A.C.G.T组成. 有一张5*5的基因表.每格有一个值,叫相似度.例:A-C:-3.意思是如果A和C配对, 则它俩的相似度是-3[P.S.:-和-没有相似度,即-和-不能配对] 现在给两条基因片段.(长度不一定相等) 现在你要在两条基因片段中插入若干个-(空白基因),使得两个基因片段长度相等,且得到的整体相似度的值最大.[再次P.S.:-和-不能配对] 思路: 因为-和-不能匹配,所以插入的-的个数是有限的. str1的第一个基因可以与str1的第一个或-配对.然后,,,,很…