POJ1080 Human Gene Functions(LCS)
题目链接。
分析:
和 LCS 差不多。
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <map> using namespace std; const int maxn = ; int G[][] = {
{, -, -, -, -},
{-, , -, -, -},
{-, -, , -, -},
{-, -, -, , -},
{-, -, -, -, }
}; int dp[maxn][maxn]; void trans(char *s, int n) {
for(int i=; i<n; i++) {
switch(s[i]) {
case 'A': s[i] = ; break;
case 'C': s[i] = ; break;
case 'G': s[i] = ; break;
case 'T': s[i] = ; break;
case '-': s[i] = ; break;
}
}
} int main(){
int T, n, m;
// freopen("my.txt", "r", stdin);
char s1[maxn], s2[maxn]; scanf("%d", &T); while(T--) {
scanf("%d%s%d%s", &n, s1, &m, s2);
trans(s1, n); trans(s2, m); dp[][] = ;
for(int i=; i<=m; i++) dp[i][] = G[s2[i-]][] + dp[i-][]; for(int i=; i<=n; i++) dp[][i] = G[s1[i-]][] + dp[][i-]; for(int i=; i<=m; i++) {
for(int j=; j<=n; j++) {
int u = s2[i-], v = s1[j-]; dp[i][j] = dp[i-][j-] + G[u][v];
dp[i][j] = max(dp[i][j], dp[i-][j]+G[u][]);
dp[i][j] = max(dp[i][j], dp[i][j-]+G[v][]);
}
} printf("%d\n", dp[m][n]);
} return ;
}
POJ1080 Human Gene Functions(LCS)的更多相关文章
- POJ 1080:Human Gene Functions LCS经典DP
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18007 Accepted: ...
- poj1080 - Human Gene Functions (dp)
题面 It is well known that a human gene can be considered as a sequence, consisting of four nucleotide ...
- POJ1080 Human Gene Functions 动态规划 LCS的变形
题意读了半年,唉,给你两串字符,然后长度不同,你能够用'-'把它们补成同样长度,补在哪里取决于得分,它会给你一个得分表,问你最大得分 跟LCS非常像的DP数组 dp[i][j]表示第一个字符串取第i个 ...
- poj 1080 Human Gene Functions(lcs,较难)
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19573 Accepted: ...
- 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 ...
- Human Gene Functions
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 18053 Accepted: 1004 ...
- poj 1080 ——Human Gene Functions——————【最长公共子序列变型题】
Human Gene Functions Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 17805 Accepted: ...
- 【POJ 1080】 Human Gene Functions
[POJ 1080] Human Gene Functions 相似于最长公共子序列的做法 dp[i][j]表示 str1[i]相应str2[j]时的最大得分 转移方程为 dp[i][j]=max(d ...
- 刷题总结——Human Gene Functions(hdu1080)
题目: Problem Description It is well known that a human gene can be considered as a sequence, consisti ...
随机推荐
- CSS 有趣的边框
今天看到一篇文章.是利用CSS边框来做折纸效果.感觉非常有意思.于是就对CSS的border研究了一下.发现还真有一些好玩的使用方法. 1.border折纸效果 首先是HTML代码,为了简单,就一个d ...
- Firemonkey的旁门左道[四]
做开发,就是发现问题,解决问题,又发现问题...周而复始的循环 下面又应该是Firemonkey下的bug. 官方文档中描述: Using the FireMonkey TMenuBar's OSMe ...
- [AngularJS] Use ng-model-options to limit $digest
Refer: http://toddmotto.com/super-fast-angular-ng-model-options-limit-digest-cycles/ Use: <input ...
- C++通过WIN32 API获取逻辑磁盘详细信息
众所周知,在微软的操作系统下编写应用程序,最主要的还是通过windows所提供的api函数来实现各种操作的,这些函数通常是可以直接使用的,只要包含windows.h这个头文件. 今天我们主要介绍的 ...
- 模拟电路"虚短" & "虚断"
<虚短 & 虚断> 运算放大器组成的电路五花八门,令人眼花瞭乱,是模拟电路中学习的重点.遍观所有模拟电子技朮的书籍和课程,在介绍运算放大器电路的时候,无非是先给电路来个定性,比如这 ...
- ADLINK 8158控制程序-连续运动(VB.NET)
运动平台:日脉的二维运动平台(一个旋转平台和一个滑动平台) 开发环境:VS2010 + .NET Framework + VB.NET 使用文件:pci_8158.vb motion_8158_2D. ...
- ASP.NET-FineUI开发实践-11
我用实例项目写了个子父页面传值,算是比较灵活的写法,可以把js提取出来写成包,然后调用,我先一步一步写,为有困难的朋友打个样. 先画个页面: 上面是个查询用的表单,底下是表格,内存分页,用到了VBox ...
- php输出金字塔
<?php for($i=0;$i<10;$i++){ for($j=1;$j<=$i;$j++){ echo $i.'*'.$j.'|'; } echo '<br>'; ...
- 解决第三方DLL没有强签名
-----转载:http://blog.csdn.net/zyming0815/article/details/5939090 创建一个新的随机密钥对:sn -k myTest.snk 第一步: 将D ...
- c# 学习笔记(二)
c#3.0 新特性 扩展方法 扩展方法允许编写和声明它的类之外的关联类的方法 用于没有源代码或者类是密封的,需要给类扩展新方法时 1.扩展方法必须被声明为static2.扩展方法声明所在的类必须被声 ...