1252: 最长公共子序列
Memory Limit:128 MB
Time Limit:1.000 S
Judge Style:Text Compare
Creator:
Submit:46
Solved:26
Description
给定一个长度为 $n$ 的字符串 $s_1$,一个长度为 $m$ 的字符串 $s_2$。
求既为 $s_1$ 的子序列又为 $s_2$ 的子序列的字符串长度最大是多少?
数据保证 $s_1$ 和 $s_2$ 只由小写字母构成。
求既为 $s_1$ 的子序列又为 $s_2$ 的子序列的字符串长度最大是多少?
数据保证 $s_1$ 和 $s_2$ 只由小写字母构成。
Input
第一行包含两个整数 $n$ 和 $m$。
第二行包含一个长度为 $n$ 的字符串,表示字符串 $s_1$。
第三行包含一个长度为 $m$ 的字符串,表示字符串 $s_2$。
第二行包含一个长度为 $n$ 的字符串,表示字符串 $s_1$。
第三行包含一个长度为 $m$ 的字符串,表示字符串 $s_2$。
Output
输出满足条件的字符串的最大长度。
Sample Input Copy
3 2
abc
ac
Sample Output Copy
2
HINT
数据范围:
$1≤n,m≤1000$。
$1≤n,m≤1000$。