#P2268. [HNOI2002] DNA 分子的最佳比对
[HNOI2002] DNA 分子的最佳比对
Description
molecules are carriers of human genetic information, indirectly guiding protein synthesis. A molecule is a long chain composed of four nucleotides: adenine nucleotide (denoted by ), guanine nucleotide (denoted by ), cytosine nucleotide (denoted by ), and thymine nucleotide (denoted by ). By convention, a -alphabet string is used to represent a sequence, such as .
During biological evolution, molecules may undergo various mutations. These mutations change genetic information, enabling species differentiation and forming biological diversity.
There are three main types of mutations:
- Inserting a new nucleotide into a sequence,
- Deleting a nucleotide from a sequence,
- Substituting one nucleotide in the sequence with another.
An alignment of two sequences is an arrangement that places the two sequences so that identical nucleotides appear at the same positions. If the nucleotides at the same position differ, that difference is attributed to one of the three types of mutations. For example, for two sequences , , one possible alignment is as follows (where denotes a gap):
Alignment 1:
Another possible alignment is:
Alignment 2:
The more identical nucleotide pairs the two sequences have at the same positions, the more similar they are, indicating functional similarity and phylogenetic relatedness.
The scoring rules for an alignment of two sequences are as follows:
- If the nucleotides at the same position are identical, score point.
- If the nucleotides at the same position are different, score points.
- If one sequence has a nucleotide at some position while the other has at that position, score points.
For example, the score of Alignment 1 is points, and the score of Alignment 2 is points.
The task is: Given two sequences, find an alignment that maximizes the score.
Input Format
The input consists of two lines.
The first line is the sequence , and the second line is the sequence . The length of each sequence does not exceed . The letters in the sequences are lowercase or uppercase English letters.
Output Format
Output the maximum score found.
Atcag
Actag
3
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号