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. 51nod 1274 最长递增路径(DP)

    一开始自己想了一种跑的巨慢..写了题解的做法又跑的巨快..一脸懵逼 显然要求边权递增就不可能经过重复的边了,那么设f[i]为第i条边出发能走多远就好了,这是我一开始的写法,可能dfs冗余状态较多,跑的 ...

  2. array_pop 剔除最后一个数组元素

    <?php $a=array("red","green","blue"); print_r(array_pop($a)); //blu ...

  3. table第一行合并,其余行宽度失效问题

    <col>标签 http://www.w3school.com.cn/tags/tag_col.asp 由于表格中有一行合并过,所以其它没有合并的行的列宽就会平均化,对列宽的设置也会失效. ...

  4. PHP扩展--Yaf框架安装

    安装/配置 编译安装 wge thttp://pecl.php.net/get/yaf-2.3.5.tgz tar -zxvfyaf-2.3.5.tgz cd yaf-2.3.5/ cd extens ...

  5. java将文件转为UTF8工具类

    package hiveTest; import java.io.BufferedReader; import java.io.DataInputStream; import java.io.File ...

  6. 省队集训 Day6 序列

    [题目大意] 给出$n$个数的序列$a_1, a_2, ..., a_n$,有$m$次操作,为下面三种: $A~l~r~d$:区间$[l,r]$,全部加$d$. $M~l~r~d$:区间$[l,r]$ ...

  7. python初步学习-pycharm使用 (二)

    pycharm调试模式 假设我们的程序在运行过程中命中了一个错误,那我们如何定位错误发生的位置?这就需要进行调试. 在Pycharm中我们可以在其中直接对程序进行调试,唯一需要做的准备工作就是在程序必 ...

  8. It is possible that this issue is resolved by uninstalling an existi

    使用真机连接Android Studio测试时出现这样的错误: 解决方法: 设置Android Studio 中Instant Run中的选项为不选中 根据以下路径,找到Instant Run中的选项 ...

  9. Windows平台下搭建Git服务器的图文教程

    Git没有客户端服务器端的概念,但是要共享Git仓库,就需要用到SSH协议(FTP , HTTPS , SFTP等协议也能实现Git共享,此文档不讨论),但是SSH有客户端服务器端,所以在window ...

  10. linux安装lamp

    github https://github.com/zblogcn/zblogphp Installation If your server system: CentOS yum -y install ...