Longest Common Subsequence
Posted zjsyzmx0527
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Longest Common Subsequence相关的知识,希望对你有一定的参考价值。
Source
https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_10_C
Description
Time Limit : 1 sec , Memory Limit : 131072 KB
Longest Common Subsequence
For given two sequences XX and YY, a sequence ZZ is a common subsequence of XX and YY if ZZ is a subsequence of both XX and YY. For example, if X={a,b,c,b,d,a,b}X={a,b,c,b,d,a,b} and Y={b,d,c,a,b,a}Y={b,d,c,a,b,a}, the sequence {b,c,a}{b,c,a} is a common subsequence of both XX and YY. On the other hand, the sequence {b,c,a}{b,c,a} is not a longest common subsequence (LCS) of XX and YY, since it has length 3 and the sequence {b,c,b,a}{b,c,b,a}, which is also common to both XX and YY, has length 4. The sequence {b,c,b,a}{b,c,b,a}is an LCS of XX and Y