ZOJ 1027
来源:互联网 发布:攻击ip软件 编辑:程序博客网 时间:2024/06/05 04:06
最长公共子序列 变形
#pragma comment(linker, "/STACK:1024000000,1024000000")#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>#include <string>#include <queue>#include <map>#include <stack>#include <set>#include <cmath>#include <vector>#define INF 0x3f#define eps 1e-6#define moo 1000000007using namespace std;#define maxn 140char str1[maxn];char str2[maxn];int len1,len2;int dp[110][110];int score[][5]={ {5,-1,-2,-1,-3}, {-1,5,-3,-2,-4}, {-2,-3,5,-2,-2}, {-1,-2,-2,5,-1}, {-3,-4,-2,-1,0} };map<char,int>map_;void init(){ map_['A']=0; map_['C']=1; map_['G']=2; map_['T']=3; map_['-']=4;}int main(){ int T; cin>>T; init(); while(T--) { scanf("%d%s",&len1,str1+1); scanf("%d%s",&len2,str2+1); dp[0][0]=0; for(int i=1;i<=len1;i++) dp[i][0]=dp[i-1][0]+score[map_[str1[i]]][4] ; for(int i=1;i<=len2;i++) dp[0][i]=dp[0][i-1]+score[4][map_[str2[i]]]; for(int i=1;i<=len1;i++) for(int j=1;j<=len2;j++) { dp[i][j]=dp[i-1][j-1]+score[map_[str1[i]]][ map_[str2[j]] ]; dp[i][j]=max(dp[i][j],dp[i-1][j]+score[map_[str1[i]]][4]); dp[i][j]=max(dp[i][j],dp[i][j-1]+score[4][map_[str2[j]]]); } cout<<dp[len1][len2]<<endl; }}
1 0
- ZOJ 1027
- ZOJ-1027
- ZOJ 1027
- ZOJ 1027
- zoj 1027解题报告
- zoj 1027 dp
- zoj 1027 简单dp
- DP--ZOJ - 1027
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- ZOJ
- 线性筛素数——Homework(2015 Facebook Hacker Cup)
- python 学习
- GPUImage使用教程
- C语言symlink()函数:建立文件符号连接
- 举例说明----索引的创建,删除,查看,分类
- ZOJ 1027
- 各大推荐引擎 整理
- $.data()的作用和理解
- bugs管理
- mac THINKPHP Call to undefined function Think\imagettftext()
- 传智播客“你有jià,我无价”活动火热开启!
- Tkinter教程之Pack篇
- resetful架构
- 尺度不变特征变换匹配算法详解