http://poj.org/problem?id=1080

 #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
using namespace std; const int INF=<<;
int score[][];
void init()
{
score['A']['C']=score['C']['A']=-;
score['A']['G']=score['G']['A']=-;
score['A']['T']=score['T']['A']=-;
score['A']['-']=score['-']['A']=-;
score['C']['G']=score['G']['C']=-;
score['C']['T']=score['T']['C']=-;
score['C']['-']=score['-']['C']=-;
score['G']['T']=score['T']['G']=-;
score['G']['-']=score['-']['G']=-;
score['T']['-']=score['-']['T']=-;
}
int main()
{
int t,dp[][];
scanf("%d",&t);
init();
while(t--)
{
int len1,len2;
char s1[],s2[];
scanf("%d %s",&len1,s1+);
scanf("%d %s",&len2,s2+);
for (int i = ; i <= len1; i++)
{
for (int j = ; j <= len2; j++)
{
dp[i][j] = -INF;
}
}
dp[][] = ;
for (int i = ; i <= len2; i++)
{
dp[][i] = dp[][i-]+score[s2[i]]['-'];
}
for (int j = ; j <= len1; j++)
{
dp[j][] = dp[j-][]+score[s1[j]]['-'];
}
for (int i = ; i <= len1; i++)
{
for (int j = ; j <= len2; j++)
{
if (s1[i]!=s2[j])
{
dp[i][j] = max(dp[i][j],dp[i-][j-]+score[s1[i]][s2[j]]);
dp[i][j] = max(dp[i][j],
max(dp[i-][j]+score[s1[i]]['-'],dp[i][j-]+score['-'][s2[j]]));
}
else
{
dp[i][j] = max(dp[i][j],dp[i-][j-]+);
}
}
}
printf("%d\n",dp[len1][len2]);
}
return ;
}

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

  1. poj1080 - Human Gene Functions (dp)

    题面 It is well known that a human gene can be considered as a sequence, consisting of four nucleotide ...

  2. poj 1080 Human Gene Functions(dp)

    题目:http://poj.org/problem?id=1080 题意:比较两个基因序列,测定它们的相似度,将两个基因排成直线,如果需要的话插入空格,使基因的长度相等,然后根据那个表格计算出相似度. ...

  3. POJ 1080:Human Gene Functions LCS经典DP

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 18007   Accepted:  ...

  4. Human Gene Functions

    Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 1004 ...

  5. poj1080--Human Gene Functions(dp:LCS变形)

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17206   Accepted:  ...

  6. hdu1080 Human Gene Functions() 2016-05-24 14:43 65人阅读 评论(0) 收藏

    Human Gene Functions Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. poj 1080 ——Human Gene Functions——————【最长公共子序列变型题】

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17805   Accepted:  ...

  8. 【POJ 1080】 Human Gene Functions

    [POJ 1080] Human Gene Functions 相似于最长公共子序列的做法 dp[i][j]表示 str1[i]相应str2[j]时的最大得分 转移方程为 dp[i][j]=max(d ...

  9. poj 1080 Human Gene Functions(lcs,较难)

    Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19573   Accepted:  ...

随机推荐

  1. 【sqli-labs】 less58 GET -Challenge -Double Query -5 queries allowed -Variation1 (GET型 挑战 双查询 只允许5次查询 变化1)

    单引号闭合成功,但是union select结果不对 http://192.168.136.128/sqli-labs-master/Less-58/?id=0' union select 1,2,3 ...

  2. Ubuntu无线转有线教程

    本来想测试一下有线转无线的,奈何网卡不支持,所以就测试了一回无线转有线的测试!(真无聊,不过也算学习一下linux网桥的知识) ca0gu0@ub:~$ sudo brctl addbr br0 #添 ...

  3. NSOperationQueue和GCD的区别,以及在什么场合下使用

    1> GCD是纯C语言的API .NSOperationQueue是基于GCD的OC的封装. 2> GCD只支持FIFO队列,NSOperationQueue可以方便设置执行顺序,设置最大 ...

  4. STL中队列queue的用法

    头文件:#include <queue> 建立一个队列queue < 类型 > q 加入一个新的元素q.push(a) 询问队首元素q.front() 弹出队首元素q.pop( ...

  5. 13.multi_match实现dis_max+tie_breaker

    主要知识点: 基于multi_match语法实现dis_max+tie_breaker     1.best_fields+tie_breaker GET /forum/article/_search ...

  6. Switch组件

    Switch组件,业务需求中经常遇到.我司的旧项目中,由于没有使用较为成熟点的组件库.自己实现了一个switch组件,但是实现的略微有些丑陋. 实现基本需求 https://jsfiddle.net/ ...

  7. scrapy实例matplotlib脚本下载

    利用scrapy框架实现matplotlib实例脚本批量下载至本地并进行文件夹分类:话不多说上代码: 首先是爬虫代码: import scrapy from scrapy.linkextractors ...

  8. Python-程序的控制结构

    程序的分支结构 >单分支结构 根据判断条件结果而选择不同向前路径的运行方式 if <条件>: <语句块> 代码示例: guess = eval(input()) if g ...

  9. 第七节:pandas排序

    pandas具有两种排序方式:sort_index()和sort_values().

  10. 敏捷开发系列学习总结(4)—Git管理工具sourcetree的安装

    现在代码管理都流行用git了,小编以前用过clearcase, svn,vss等.现在用了git后,发现git才是最好的,我觉得它最吸引人的地方应该是它的分布式管理吧.git的具体学习,读者可自己去网 ...