#P1140. 相似基因
相似基因
Description
The similarity between two genes is computed as follows:
For two given genes, for example AGTGATG and GTTAG, align their bases with each other. Of course, you may insert some gap bases - in between, for example:
Then the similarity between the two genes can be described as the sum of pairwise base similarities, as shown in the following table:
$$\def\arraystretch{1.5} \begin{array}{ |c|c|c|c|c|c|} \hline & \tt A & \tt C & \tt G & \tt T & \texttt - \\ \hline \tt A & 5 & -1 & -2 & -1 & -3\\ \hline \tt C & -1 & 5 & -3 & -2 & -4 \\\hline \tt G & -2 & -3 & 5 & -2 & -2 \\\hline \tt T & -1 & -2 & -2 & 5 & -1 \\\hline \texttt - & -3 & -4 & -2 & -1 & * \\\hline \end{array}$$Thus the similarity is: . Since the alignment between two genes is not unique, for example:
$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt T & \texttt A & \texttt - & \tt G \\ \hline \end{array}$$The similarity is: . Define the similarity between two genes as the maximum similarity among all alignments.
Input Format
There are two lines. Each line first contains an integer , representing the length of the gene sequence; after a space is a gene sequence that contains only the four letters . .
Output Format
Only one line: the similarity of the input genes.
7 AGTGATG
5 GTTAG
14
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号