题意读了半年,唉,给你两串字符,然后长度不同,你能够用'-'把它们补成同样长度,补在哪里取决于得分,它会给你一个得分表,问你最大得分 跟LCS非常像的DP数组 dp[i][j]表示第一个字符串取第i个元素第二个字符串取第三个元素,然后再预处理一个得分表加上就可以 得分表: score['A']['A'] = score['C']['C'] = score['G']['G'] = score['T']['T'] = 5; score['A']['C'] = score['C']['A'] = -1…
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…
题面 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…
题目地址: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…
题目链接. 分析: 和 LCS 差不多. #include <iostream> #include <cstdio> #include <cstdlib> #include <cstring> #include <map> using namespace std; ; ] = { {, -, -, -, -}, {-, , -, -, -}, {-, -, , -, -}, {-, -, -, , -}, {-, -, -, -, } }; in…
题目链接: https://cn.vjudge.net/problem/POJ-1080 题目大意: 给定两组序列,要你求出它们的最大相似度,每个字母与其他字母或自身和空格对应都有一个打分,求在这两个字符串中插入空格,让这两个字符串的匹配分数最大 解题思路: 类似LCS,以dp[i][j]表示s1前i位和s2前j位的最优解. 递推式为: 先不考虑括号 dp[i][j]只由dp[i-1][j-1]递推而来 if(s1[i] == s2[j])dp[i][j] = dp[i - 1][j - 1]…
Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17206   Accepted: 9568 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: 18007   Accepted: 10012 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: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3103    Accepted Submission(s): 1761 Problem Description It is well known that a human gene can be considered as a sequence,…
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 10046 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 let…
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…
[POJ 1080] Human Gene Functions 相似于最长公共子序列的做法 dp[i][j]表示 str1[i]相应str2[j]时的最大得分 转移方程为 dp[i][j]=max(dp[i-1][j-1]+score[str1[i]][str2[j]], max(dp[i-1][j]+score[str1[i]]['-'],dp[i][j-1]+score['-'][str2[j]]) ) 注意初始化0下标就好 代码例如以下: #include <iostream> #inc…
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 identifying human genes and determining their…
题目: Problem 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 identifying human genes and deter…
Problem 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 identifying human genes and  determin…
http://poj.org/problem?id=1080 (题目链接) 题意 给出两个只包含字母ACGT的字符串s1.s2,可以在两个字符串中插入字符“-”,使得s1与s2的相似度最大. Solution 动态规划. 用f[i][j]表示字符串s1前i位和s2前j位的最大相似度,转移很简单,直接看程序吧,边界条件要注意,当i=0或j=0时,就等于是在长度等于0的字符串中全部插入“-”,使得两字符串长度相等的相似度.打个表预处理出每两个字符的相似度比较方便后面的操作. 代码 // poj108…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1027 http://poj.org/problem?id=1080 解题报告: 1.类似于LCS 2.gene[i][j]表示str1[i-1]和str2[j-1]的分值串没有,则应该扣分 3.递推公式 temp1=gene[i-1][j-1]+score[_map[str1[i-1]]][_map[str2[j-1]]]; temp2=gene[i-1][j]…
题意:求出将两个字符串改成一样长度所能形成最大的相似度. 思路:这个可以说是编辑距离的一个变形,编辑距离最终状态时要两个字符串完全一致,这个就是要求长度一样,而且这个只允许插入“—”这一个字符.模仿编辑距离定义状态,dp[i][j]表示将第一个字符串的前i个字符与第二个字符串的前j个字符变为相同长度所能形成的最大相似度.设两个字母的相似度为g[i][j]; 那状态转移为 dp[i][j] = max( dp[i][j-1] + g[j][5], d[i-1][j] + g[i][5],dp[i-…
传送门 题目大意: 将两个字符串对齐(只包含ACGT,可以用'-'占位),按照对齐分数表(参见题目)来计算最后的分数之和,输出最大的和. 例如:AGTGATG 和 GTTAG ,对齐后就是(为了表达对齐,这里我用m表示'-') AGTGATG mGTTAmG 题目分析: 首先看出这道题与LCS有关,下面来考虑转移: 当t1[i]==t2[j]时,和LCS一样,\(dp[i][j] = dp[i-1][j-1]+score[t1[i]][t2[j]]\) 当t1[i]!=t2[j]时,唯一不同的是…
题目链接 题目:给出两个串,每匹配一种有一种权值,求权值最大的匹配串 就是 最长公共子序列的 的思想: 首先对于 i 和 j 来比较, 一种情况是i和j匹配,此时 dp[i][j] = dp[i - 1][j - 1] + g[ str1[i] ][ str2[j] ],另一种情况是i和j不匹配,那么就有两种情况,一 i 和 j前面的匹配,j与一个空 即 ‘ - ’匹配,dp[i][j] = dp[i ][ j - 1] + g[ ' - ' ][ str2[j] ] ,二 i 前面的 和 j匹…
题意:有两个代表基因序列的字符串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[…
大概作了一周,终于A了 类似于求最长公共子序列,稍有变形 当前序列 ch1 中字符为 a,序列 ch2 中字符为 b 则有 3 种配对方式: 1. a 与 b 2. a 与 - 3. - 与 b 动态转移方程: dp[i][j] = max(dp[i - 1][j - 1] + g(ch1[i],ch2[j]) , dp[i - 1][j] + g(ch1[i],‘-') , dp[i][j-1] + g('-',ch2[j])) 代码如下: #include<stdio.h> #includ…
最长公共子序列的变形 题目大意:给出两个基因序列,求这两个序列的最大相似度. 题目中的表格给出了两两脱氧核苷酸的相似度. 状态转移方程为: dp[i][j] = max(dp[i-1][j]+Similarity(s1[i], '-'),                     dp[i][j-1]+Similarity(s2[j], '-'),                     dp[i-1][j-1]+Similarity(s1[i], s2[j])); 注意边界的初始化. //#de…
一道动态规划,两个串进行匹配,不同字母匹配的值不一样,也可以和空格匹配(空格不能与空格匹配),求最大的匹配值. 数据很弱,每个串都在100以内. 定义dp[i][j]为第一个串前i个数和第二个串前j个数已匹配的匹配值 有三种情况:1.第i个和第j个匹配                       2.第i个和'-'匹配                       3.第j个和'-'匹配 注意合理初始化 #include<cstdio> #include<algorithm> #in…
题目大意:每次给出两个碱基序列(包含ATGC的两个字符串),其中每一个碱基与另一串中碱基如果配对或者与空串对应会有一个分数(可能为负),找出一种方式使得两个序列配对的分数最大 思路:字符串动态规划的经典题,很容易想到状态dp[i][j],指第一个长度为i的串和第二个长度为j的串配对的最大分数.显然,这个状态可以由dp[i][j-1],dp[i-1][j],dp[i-1][j-1]三个子问题得到,即第一串最后一个字符对应空格.第二串最后一个字符对应空格和第一串第二串最后一个字符配对所得到的分数这三…
题目大意是:给定两组DNA序列,要你求出它们的最大相似度 每个字母与其他字母或自身和空格对应都有一个打分,求在这两个字符串中插入空格,让这两个字符串的匹配分数最大 /* 思路是很好想的,设f[i][j]为A染色体前i个基因和B染色体前j个基因匹配的最大值 第一次测样例WA了一把,f又没有赋最小值,今天第二次了,幸亏样例测出来了,不然又要WA一次. */ #include<cstdio> #include<iostream> #include<cstring> #defi…
题意:给两个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[…
题目: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(‘-’)];…
题目链接: http://poj.org/problem?id=1080 题目大意: 给两个由A.C.T.G四个字符组成的字符串,可以在两串中加入-,使得两串长度相等. 每两个字符匹配时都有个值,求怎样安排使得总的值最大,两个-不能匹配. 解题思路: 这题转化一下就是一个裸的最长公共子串问题,只不过要求匹配时长度一样. dp[i][j]表示第一串的第前i个字符和第二串的前j个字符匹配时,能达到的最大值. 初始化时注意dp[0][j]和dp[j][0]不能为零,为相应字符与-匹配时的总和. 代码:…
DP.wa了一下午,原来是把mmax写在外层循环了.最近事情太多了,刷题根本没状态. #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <iostream> using namespace std; #define MAXN 205 #define INF -99999 #define TOKEN '-' char r[MAXN], l[…