## G.Human Gene Functions

**Question:** Given two DNA strings, find the maximum similarity

**analysis:** deformed $LCS$ question, please type out the form first,$dp(i,j)$ represents the string$i$ and stringjjThe maximum similarity of$j$ , and then use$LCS$ transfers in the same way.

## Code:

```
#include<iostream>
#include<algorithm>
#include<string.h>
using namespace std;
const int N=105;
int t,n,m,x[127][127],dp[N][N];
char s1[N],s2[N];
int main(){
x['A']['A']=x['T']['T']=x['G']['G']=x['C']['C']=5;
x['A']['C']=x['A']['T']=x['C']['A']=x['T']['A']=x['T']['-']=x['-']['T']=-1;
x['A']['G']=x['C']['T']=x['G']['A']=x['G']['T']=x['G']['-']=x['T']['C']=x['T']['G']=x['-']['G']=-2;
x['A']['-']=x['C']['G']=x['G']['C']=x['-']['A']=-3;
x['C']['-']=x['-']['C']=-4;
cin>>t;
while(t--){
cin>>n>>s1+1>>m>>s2+1;
memset(dp,0,sizeof dp);
for(int i=1;i<=n;i++) dp[i][0]=dp[i-1][0]+x[s1[i]]['-'];
for(int i=1;i<=m;i++) dp[0][i]=dp[0][i-1]+x['-'][s2[i]];
for(int i=1;i<=n;i++)
for(int j=1;j<=m;j++)
dp[i][j]=max(dp[i-1][j-1]+x[s1[i]][s2[j]],max(dp[i-1][j]+x[s1[i]]['-'],dp[i][j-1]+x['-'][s2[j]]));
cout<<dp[n][m]<<endl;
}
}
```