Human Gene Functions

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3008    Accepted Submission(s): 1701

Problem Description
It
is well known that a human gene can be considered as a sequence,
consisting of four nucleotides, which are simply denoted by four
letters, A, C, G, and T. Biologists have been interested in identifying
human genes and determining their functions, because these can be used
to diagnose human diseases and to design new drugs for them.

A
human gene can be identified through a series of time-consuming
biological experiments, often with the help of computer programs. Once a
sequence of a gene is obtained, the next job is to determine its
function. One of the methods for biologists to use in determining the
function of a new gene sequence that they have just identified is to
search a database with the new gene as a query. The database to be
searched stores many gene sequences and their functions – many
researchers have been submitting their genes and functions to the
database and the database is freely accessible through the Internet.

A
database search will return a list of gene sequences from the database
that are similar to the query gene. Biologists assume that sequence
similarity often implies functional similarity. So, the function of the
new gene might be one of the functions that the genes from the list
have. To exactly determine which one is the right one another series of
biological experiments will be needed.

Your job is to make a
program that compares two genes and determines their similarity as
explained below. Your program may be used as a part of the database
search if you can provide an efficient one.

Given two genes
AGTGATG and GTTAG, how similar are they? One of the methods to measure
the similarity of two genes is called alignment. In an alignment, spaces
are inserted, if necessary, in appropriate positions of the genes to
make them equally long and score the resulting genes according to a
scoring matrix.

For example, one space is inserted into AGTGATG
to result in AGTGAT-G, and three spaces are inserted into GTTAG to
result in –GT--TAG. A space is denoted by a minus sign (-). The two
genes are now of equal length. These two strings are aligned:

AGTGAT-G
-GT--TAG

In
this alignment, there are four matches, namely, G in the second
position, T in the third, T in the sixth, and G in the eighth. Each pair
of aligned characters is assigned a score according to the following
scoring matrix.

* denotes that a space-space match is not allowed. The score of the alignment above is (-3)+5+5+(-2)+(-3)+5+(-3)+5=9.

Of
course, many other alignments are possible. One is shown below (a
different number of spaces are inserted into different positions):

AGTGATG
-GTTA-G

This
alignment gives a score of (-3)+5+5+(-2)+5+(-1) +5=14. So, this one is
better than the previous one. As a matter of fact, this one is optimal
since no other alignment can have a higher score. So, it is said that
the similarity of the two genes is 14.

 
Input
The
input consists of T test cases. The number of test cases ) (T is given
in the first line of the input. Each test case consists of two lines:
each line contains an integer, the length of a gene, followed by a gene
sequence. The length of each gene sequence is at least one and does not
exceed 100.
 
Output
The output should print the similarity of each test case, one per line.
 
Sample Input
2
7 AGTGATG
5 GTTAG
7 AGCTATT
9 AGCTTTAAA
 
Sample Output
14
21
 
Source
 
题意:给你两个串,问在哪些位置添加多少个-号可以使权值最大。
 
分析:和LCS差不多吧。。分三个状态考虑。。下午训练时,状态方程出来了初始化一直没想到一直没出答案,无心再想这个题了。。今天先记录下吧。。
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<iostream>
#define N 105
using namespace std; int mp[][]=
{
{,-,-,-,-},
{-,,-,-,-},
{-,-,,-,-},
{-,-,-,,-},
{-,-,-,-,}
};
int dp[N][N];
int main()
{
int tcase;
scanf("%d",&tcase);
while(tcase--)
{
int n,m;
char str1[],str2[];
scanf("%d%s",&n,str1+);
scanf("%d%s",&m,str2+);
memset(dp,,sizeof(dp));
int x,y;
for(int i=; i<=n; i++) ///这里很重要
{
if(str1[i]=='A') y=;
if(str1[i]=='C') y=;
if(str1[i]=='G') y=;
if(str1[i]=='T') y=;
dp[i][] = dp[i-][] + mp[y][];
}
for(int i=; i<=m; i++)
{
if(str2[i]=='A') x=;
if(str2[i]=='C') x=;
if(str2[i]=='G') x=;
if(str2[i]=='T') x=;
dp[][i] = dp[][i-] + mp[][x];
} for(int i=; i<=n; i++)
{
for(int j=; j<=m; j++)
{ if(str1[i]=='A') x=;
if(str1[i]=='C') x=;
if(str1[i]=='G') x=;
if(str1[i]=='T') x=;
if(str2[j]=='A') y=;
if(str2[j]=='C') y=;
if(str2[j]=='G') y=;
if(str2[j]=='T') y=;
dp[i][j] = max(dp[i-][j-]+mp[x][y],max(dp[i-][j]+mp[][x],dp[i][j-]+mp[][y]));
}
}
//for(int i=1;i<=n;i++)
printf("%d\n",dp[n][m]);
}
return ;
}

hdu 1080(LCS变形)的更多相关文章

  1. Advanced Fruits(HDU 1503 LCS变形)

    Advanced Fruits Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)T ...

  2. hdu 1243(LCS变形)

    反恐训练营 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submi ...

  3. POJ 1080( LCS变形)

    题目链接: http://poj.org/problem?id=1080 Human Gene Functions Time Limit: 1000MS   Memory Limit: 10000K ...

  4. poj 1080 (LCS变形)

    Human Gene Functions 题意: LCS: 设dp[i][j]为前i,j的最长公共序列长度: dp[i][j] = dp[i-1][j-1]+1;(a[i] == b[j]) dp[i ...

  5. hdu 1087(LIS变形)

    Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  6. DP问题(3) : hdu 1080

    题目转自hdu 1080,题目传送门 题目大意: 不想翻译! 解题思路: 其实就是一道变异的求lcs(Longest common subsequence 最长公共子序列)的题 不过,它的依据是下面这 ...

  7. UVA-1625-Color Length(DP LCS变形)

    Color Length(UVA-1625)(DP LCS变形) 题目大意 输入两个长度分别为n,m(<5000)的颜色序列.要求按顺序合成同一个序列,即每次可以把一个序列开头的颜色放到新序列的 ...

  8. HDU 5791 Two ——(LCS变形)

    感觉就是最长公共子序列的一个变形(虽然我也没做过LCS啦= =). 转移方程见代码吧.这里有一个要说的地方,如果a[i] == a[j]的时候,为什么不需要像不等于的时候那样减去一个dp[i-1][j ...

  9. hdu 1080 dp(最长公共子序列变形)

    题意: 输入俩个字符串,怎样变换使其所有字符对和最大.(字符只有'A','C','G','T','-') 其中每对字符对应的值如下: 怎样配使和最大呢. 比如: A G T G A T G -  G ...

随机推荐

  1. 关于notepad++如何自动补全标签的问题

    转自:https://blog.csdn.net/Panda_Eyes1/article/details/81486331 关于notepad++如何自动补全标签的问题 2018年08月07日 18: ...

  2. ACM1198Farm Irrigation

    这个题目好吓人呀!嘿嘿--- 不过仔细分析下就可以啦! #include<iostream> #include<cstring> using namespace std; ; ...

  3. Android Eclipse 开发环境搭建

    因为开发工具版本 搭建 环境配置经常出现问题 再次用一篇随笔来做下记录 1 需要的工具jdk-6u45-windows-x64 //http://www.oracle.com/technetwork/ ...

  4. js的数据类型--字符串

    js的数据类型——字符串 这篇我们来说说js的第二种数据类型——字符串. js的内置功能之一就是字符串拼接.如果将加号(+)运算符用于数字,表示两数相加.但将它作用于字符串,则表示字符串拼接,将第二个 ...

  5. 与http协作的web服务器、http首部(第五章、第六章)

    第五章 与http协作的web服务器 1.用单台虚拟主机实现多个域名 通过域名访问主机,经过DNS解析成ip地址,反向代理,可以代理多台服务器,正向代理则相反,代理客户端 2.通信数据转化程序:代理. ...

  6. JAVA嵌套类:静态嵌套类和非静态嵌套类

    1.内部类定义 内部类在维基百科的定义为:  面向对象编程中,内部类(又叫做嵌套类)是在另一个类或者接口中进行声明的类.内部类不同于子类(subclass).(译者注:wiki的注解有误,内部类和嵌套 ...

  7. 【BZOJ4517】【SDOI2016】排列计数 [数论]

    排列计数 Time Limit: 60 Sec  Memory Limit: 128 MB[Submit][Status][Discuss] Description 求有多少种长度为 n 的序列 A, ...

  8. bzoj3671 [Noi2014]随机数生成器

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=3671 [题解] 贪心从1...n*m取,开两个5000*5000的数组就够了,可以重复利用, ...

  9. HDU5852 Intersection is not allowed!

    There are K pieces on the chessboard. The size of the chessboard is N*N. The pieces are initially pl ...

  10. ”未能加载文件或程序集“Oracle.DataAccess”或它的某一个依赖项

    引用:http://www.cnblogs.com/joey0210/archive/2012/09/29/2708420.html 上一篇文章说到了DLL引用问题,主要是说的程序中如果使用过了反射, ...