V. 相似基因

    Type: RemoteJudge 1000ms 125MiB

相似基因

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目背景

大家都知道,基因可以看作一个碱基对序列。它包含了 44 种核苷酸,简记作 A, C, G, T。生物学家正致力于寻找人类基因的功能,以利用于诊断疾病和发明药物。

在一个人类基因工作组的任务中,生物学家研究的是:两个基因的相似程度。因为这个研究对疾病的治疗有着非同寻常的作用。

题目描述

两个基因的相似度的计算方法如下:

对于两个已知基因,例如 AGTGATGGTTAG,将它们的碱基互相对应。当然,中间可以加入一些空碱基 -,例如:

$$\def\arraystretch{1.5} \begin{array}{|c|c|c|c|c|c|c|c|} \hline \tt A & \tt G & \tt T & \tt G & \tt A & \tt T & \texttt - & \tt G \\ \hline \texttt - & \tt G & \tt T & \texttt - & \texttt - & \tt T & \texttt A & \tt G \\ \hline \end{array} $$

这样,两个基因之间的相似度就可以用碱基之间相似度的总和来描述,碱基之间的相似度如下表所示:

$$\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} $$

那么相似度就是:(3)+5+5+(2)+(3)+5+(3)+5=9(-3)+5+5+(-2)+(-3)+5+(-3)+5=9。因为两个基因的对应方法不唯一,例如又有:

$$\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} $$

相似度为:(3)+5+5+(2)+5+(1)+5=14(-3)+5+5+(-2)+5+(-1)+5=14。规定两个基因的相似度为所有对应方法中,相似度最大的那个。

输入格式

共两行。每行首先是一个整数 nn,表示基因序列的长度;隔一个空格后是一个基因序列,序列中只含 A,C,G,T\verb!A!,\verb!C!,\verb!G!,\verb!T! 四种字母。1n1001 \le n\le 100

输出格式

仅一行,即输入基因的相似度。

7 AGTGATG
5 GTTAG

14

【蒙青创】2025年CSP-J/S 冲刺【线性DP】

Not Claimed
Status
Done
Problem
31
Open Since
2025-9-13 0:00
Deadline
2025-10-25 23:59
Extension
24 hour(s)