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 ;
}

最新文章

  1. ASP.NET MVC5+EF6+EasyUI 后台管理系统(64)-WebApi与Unity注入
  2. 在Ubuntu|CentOS上安装Shutter截图工具及快捷键设置
  3. 包含块( Containing block ) 转自W3CHelp
  4. HTML5_ScrollInToView方法
  5. java之内部类(InnerClass)----非静态内部类、静态内部类、局部内部类、匿名内部类
  6. Android 判断app是否在前台运行
  7. Nginx使用手册目录
  8. windows server 2008 IP安全策略关闭端口,禁止ping,修改远程连接3389端口,开放指定端口
  9. SharePoint Server 2007 简体中文下载
  10. android面试题(转)
  11. FXBlurView用法
  12. 【poj解题】1308
  13. JavaScript学习总结 之对象
  14. Linux系统centOS7在虚拟机下的安装及XShell软件的配置
  15. python 用codecs实现数据的读取
  16. iOS 动态 Framework 对App启动时间影响实测
  17. 关于VMware虚拟机安装镜像时黑屏的解决办法
  18. [转]rancher 初步
  19. Pandas 使用笔记
  20. ASP.NET MVC应用安全性(一)——自定义错误处理

热门文章

  1. 13、scala模式匹配
  2. PHP 之文件锁解决并发问题
  3. Python编码格式导致的csv读取错误
  4. Django REST framework 分页
  5. Linux之iptables(一、防火墙的概念)
  6. sencha touch 2制作滑动DataView(无缝list)
  7. Ext.Ajax.request方法 参数
  8. PHP中Session和Cookie 快速了解与使用
  9. 温故之--Linux 初始化 init 系统
  10. [poj1062]昂贵的聘礼_最短路_离散化