hdu 1080 Human Gene Functions
2013-06-11 08:07
369 查看
//Time 0ms, Memory 288K
#include<stdio.h> #include<string.h> int main() { int i,j,la,lb,t,map[20][20],dp[105][105],x,y,z; char a[105],b[105]; memset(map,0,sizeof(map)); map[0][0]=map[2][2]=map[6][6]=map[19][19]=5; map[0][2]=map[2][0]=map[0][19]=map[19][0]=map[7][19]=-1; map[0][6]=map[6][0]=map[2][19]=map[19][2]=map[6][19]=map[19][6]=map[7][6]=-2; map[2][6]=map[6][2]=map[7][0]=-3; map[7][2]=-4; scanf("%d",&t); while(t--) { scanf("%d%s%d%s",&la,a,&lb,b); dp[0][0]=0; for(i=1;i<=la;i++) { dp[i][0]=dp[i-1][0]+map[7][a[i-1]-65]; } for(j=1;j<=lb;j++) { dp[0][j]=dp[0][j-1]+map[7][b[j-1]-65]; } for(i=1;i<=la;i++) { for(j=1;j<=lb;j++) { x=dp[i-1][j-1]+map[a[i-1]-65][b[j-1]-65]; y=dp[i][j-1]+map[7][b[j-1]-65]; z=dp[i-1][j]+map[7][a[i-1]-65]; y=y>z?y:z; dp[i][j]=x>y?x:y; } } printf("%d\n",dp[la][lb]); } return 0; }
相关文章推荐
- 【DP|LCS】HDU-1080 Human Gene Functions
- HDU 1080 Human Gene Functions 带权的最长公共子序列
- HDU 1080 Human Gene Functions(LCS变形)
- hdu-1080 Human Gene Functions
- hdu——1080——Human Gene Functions
- hdu 1080 Human Gene Functions
- hdu 1080 Human Gene Functions (LCS变形)
- hdu 1080 Human Gene Functions (LCS的变形)
- hdu 1080 Human Gene Functions 线性dp
- HDU 1080 Human Gene Functions(LCS变形)
- hdu 1080 Human Gene Functions( 类似最长公共子序列)
- hdu 1080 Human Gene Functions (dp)
- HDU 1080 Human Gene Functions(最长公共子序列变形)
- HDU 1080 Human Gene Functions (DP)
- 【Hdu】1080 Human Gene Functions
- HDU1080——Human Gene Functions
- hdu 1080 Human Gene Functions(dp)
- hdu 1080 Human Gene Functions
- hdu 1080 Human Gene Functions(带权值的最大子序列)
- hdu 1080 Human Gene Functions (编辑距离问题)