#P1446B. Catching Cheaters
Catching Cheaters
No submission language available for this problem.
Description
You are given two strings and representing essays of two students who are suspected cheaters. For any two strings , we define their similarity score as , where denotes the length of the Longest Common Subsequence of strings and .
You believe that only some part of the essays could have been copied, therefore you're interested in their substrings.
Calculate the maximal similarity score over all pairs of substrings. More formally, output maximal over all pairs , where is some substring of , and is some substring of .
If is a string, denotes its length.
A string is a substring of a string if can be obtained from by deletion of several (possibly, zero or all) characters from the beginning and several (possibly, zero or all) characters from the end.
A string is a subsequence of a string if can be obtained from by deletion of several (possibly, zero or all) characters.
Pay attention to the difference between the substring and subsequence, as they both appear in the problem statement.
You may wish to read the Wikipedia page about the Longest Common Subsequence problem.
The first line contains two positive integers and () — lengths of the two strings and .
The second line contains a string consisting of lowercase Latin letters — string .
The third line contains a string consisting of lowercase Latin letters — string .
Output maximal over all pairs , where is some substring of , and is some substring of .
Input
The first line contains two positive integers and () — lengths of the two strings and .
The second line contains a string consisting of lowercase Latin letters — string .
The third line contains a string consisting of lowercase Latin letters — string .
Output
Output maximal over all pairs , where is some substring of , and is some substring of .
Samples
Note
For the first case:
abb from the first string and abab from the second string have LCS equal to abb.
The result is ) - - = .