poj 1080】的更多相关文章

http://poj.org/problem?id=1080 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=27 /* zoj 1027 poj 1080 思路: 三种状态,取最大值: s1[i]和s2[j]配 :dp[i-1][j-1]+cost[my[s1[i]]][my[s2[j]]]; s1[i]和'-' 配: dp[i-1][j]+cost[my[s1[i]]][my['-']]; s2[j]和'-' 配: dp[…
[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…
题目: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 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 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; ; const int INF = 0x3f3f3f; int dp[maxn][maxn]; int A[maxn],B[maxn]; ][] = { {, , , , , }, {,,-,-,-,…
题目链接: http://poj.org/problem?id=1080 题目大意: 给两个由A.C.T.G四个字符组成的字符串,可以在两串中加入-,使得两串长度相等. 每两个字符匹配时都有个值,求怎样安排使得总的值最大,两个-不能匹配. 解题思路: 这题转化一下就是一个裸的最长公共子串问题,只不过要求匹配时长度一样. dp[i][j]表示第一串的第前i个字符和第二串的前j个字符匹配时,能达到的最大值. 初始化时注意dp[0][j]和dp[j][0]不能为零,为相应字符与-匹配时的总和. 代码:…
http://poj.org/problem?id=1080 知识点 :最长公共子序列 要点: 转移方程  f[i][j]  = max{ f[i-i][j]+score[s1[i-1]]['-'],  f[i][j-1]+score['-'][s2[j-1]],  f[i-1][j-1]+score[s1[i-1]][s2[j-1]]} #include <iostream> using namespace std; ][]; ][]; ],s2[]; void init(){ score[…
题目链接: http://poj.org/problem?id=1080 Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 20430   Accepted: 11396 Description It is well known that a human gene can be considered as a sequence, consisting of four nucleoti…
要求max{F/P},先枚举下界lowf,再贪心求符合约束条件的n个最小价值和 记录F的离散值和去重可以大幅度常数优化 (本来想着用DP做的) (辣鸡POJ连auto都Complie Error) #include<iostream> #include<algorithm> #include<cstdio> #include<cstring> #include<vector> #include<iterator> using name…
Human Gene Functions 题意: LCS: 设dp[i][j]为前i,j的最长公共序列长度: dp[i][j] = dp[i-1][j-1]+1;(a[i] == b[j]) dp[i][j] = max(dp[i][j-1],dp[i-1][j]); 边界:dp[0][j] = 0(j<b.size) ,dp[i][0] = 0(i< a.size); LCS变形: 设dp[i][j]为前i,j的最大价值: value(x, y)为比较价值: dp[i][j] = max(d…