#T238. 公共子序列

公共子序列

Description

Given two integer sequences, write a program to find their longest increasing common subsequence.
A sequence S~1~, S~2~, ..., S~N~ of length N is called an increasing subsequence of a sequence A~1~, A~2~, ..., A~M~ of length M when the following conditions are satisfied:
There exist indices 1 ≤ i~1~ < i~2~ < ... < i~N~ ≤ M such that for all 1 ≤ j ≤ N, S~j~ = A~i~j~, and for all 1 ≤ j < N, S~j~ < S~j+1~.

Input Format

The input consists of multiple test cases. Each test case contains one line with two strings of length no more than 200, representing the two sequences. The two strings are separated by one or more spaces.

Output Format

For each test case, output one line containing the length of the longest common increasing subsequence of the two sequences.

abcfbc abfcab
programming contest 
abcd mnp

4
2
0