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 ...
随机推荐
- “too many open files" ----增大打开的文件数
http://www.cnblogs.com/ibook360/archive/2012/05/11/2495405.html [root@localhost ~]# ab -n -c http:/ ...
- iOS 开发-单元测试
前言 维基百科对单元测试的定义如下: 在计算机编程中,单元测试(英语:Unit Testing)又称为模块测试, 是针对程序模块(软件设计的最小单位)来进行正确性检验的测试工作.程序单元是应用的最小可 ...
- Codeforces Round #291 (Div. 2) C - Watto and Mechanism 字符串
[题意]给n个字符串组成的集合,然后有m个询问(0 ≤ n ≤ 3·105, 0 ≤ m ≤ 3·105) ,每个询问都给出一个字符串s,问集合中是否存在一个字符串t,使得s和t长度相同,并且仅有一个 ...
- display:box和flex的区别
没区别,仅是各阶段草案命名flex是最新的 但是在实际的浏览器测试中,display: flex 不能完全替代display: -webkit-box display: box 使用可以参考http: ...
- PHP微信公众号 access_token缓存
PHP创建access_token.json文件,将access_token 和 生成时间expires 保存在其中, {"access_token":"xxxx&quo ...
- 使用Android SDK Manager自动下载速度慢解决方法
可以在SDK Manager 的更新界面,勾选下载项并去android-sdk-windows\temp文件家中查找文件名称例如:android-2.3.1_r02-linux.zip在前面加上链接h ...
- 修改DeDe标签Pagelist分页样式
我们在用dede仿站的时候,调用文章列表页的分页时,我们会用到: {dede:pagelist listitem=”info,index,end,pre,next,pageno” listsize=” ...
- Python文件操作方法
python中对文件.文件夹(文件操作函数)的操作需要涉及到os模块和shutil模块. 得到当前工作目录,即当前Python脚本工作的目录路径: os.getcwd() 返回指定目录下的所有 ...
- oracle特殊字符的ascii值
- C++学习之DLL注入
#include<stdio.h> #include<Windows.h> #include<TlHelp32.h> //typedef unsigned long ...