-->
当前位置:首页 > 题库

PROGRAMMING:LCS

Luz5年前 (2021-05-10)题库420
There are two strings $$s, T $$, find out the continuous substring of $$s $$$a $$, $$t $$continuous substring $$B $$, and find the maximum value of $$4 * | LCS (a, b) | - | a | - | B | $.
$$LCS (a, b) $$represents the longest common subsequence of the string $$a, B $$
Interpretation of substrings and subsequences:
The substring $$a $$of $$s $$is defined as the string $$s $$which continuously removes a number of (can be 0) characters from the beginning and a number of (can be 0) characters from the end. The resulting string (for example, bab is the substring of Ababa; bab is the substring of Ababa; bab is the substring of Ababa; bab is the substring of Ababa; BBA is not a substring of ABA)
The subsequence of $$s $$$$a $$is defined as a string obtained by arbitrarily deleting a number of (can be 0) characters from the string $$s $$(for example, BBA is a subsequence of Ababa, bbaa is not a subsequence of Ababa)
###Input format:
In the first line, enter two integers $$n, m (1 < = n, m < = 5000)$$
Enter the string s on the second line
Enter the string t on the third line
Ensure that all strings are lowercase
###Output format:
Output an integer on a line to represent the maximum value that can be obtained
###Input example:
Here is a set of inputs. For example:
```in
4 5
abba
babab
```
###Output example:
The corresponding output is given here. For example:
```out
five
```







answer:If there is no answer, please comment