addressing expositions of two understudies who are suspected miscreants. For any two strings C, D we characterize their likeness score S(C,D) as 4⋅LCS(C,D)−|C|−|D|, where LCS(C,D) signifies the length of the Longest Common Subsequence of strings C and D. You accept that main some piece of the expositions might
Correct answer will be upvoted else Multiple Downvoted. Don't submit random answer. Computer science.
You are given two strings An and B addressing expositions of two understudies who are suspected miscreants. For any two strings C, D we characterize their likeness score S(C,D) as 4⋅LCS(C,D)−|C|−|D|, where LCS(C,D) signifies the length of the Longest Common Subsequence of strings C and D.
You accept that main some piece of the expositions might have been replicated, along these lines you're keen on their substrings.
Work out the maximal likeness score over all sets of substrings. All the more officially, output maximal S(C,D) over all sets (C,D), where C is some substring of A, and D is some substring of B.
In case X is a string, |X| means its length.
A string a will be a substring of a string b if a can be acquired from b by erasure of a few (potentially, zero or all) characters from the start and a few (conceivably, zero or all) characters from the end.
A string a will be an aftereffect of a string b if a can be gotten from b by cancellation of a few (conceivably, zero or all) characters.
Focus on the distinction between the substring and aftereffect, as the two of them show up in the issue articulation.
You might wish to peruse the Wikipedia page about the Longest Common Subsequence issue.
Input
The main line contains two positive integers n and m (1≤n,m≤5000) — lengths of the two strings An and B.
The subsequent line contains a string comprising of n lowercase Latin letters — string A.
The third line contains a string comprising of m lowercase Latin letters — string B.
Output
Output maximal S(C,D) over all sets (C,D), where C is some substring of A, and D is some substring of B.
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 4 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)