ZOJ Problem Set - 2432
You are given two sequences of integer numbers. Write a program to determine their common increasing subsequence of maximal
Sequence S1, S2, ..., SN of length N is called an increasing subsequence of
a sequence A1, A2, ..., AM of length M if there exist 1 <= i1 < i2 <
...< iN <= M such that Sj = Aij for all 1 <= j <= N, and Sj <
Sj+1 for all 1 <= j < N.
Each sequence is described with M - its length (1 <= M <= 500) and M integer numbers Ai (-2^31 <= Ai < 2^31) - the sequence itself.
On the first line of the output print L - the length of the greatest common increasing subsequence of both sequences. On the second line print the subsequence itself. If there are several possible answers, output any of them.
The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.
The output format consists of N output blocks. There is a blank line between
Source: Northeastern Europe 2003, Northern Subregion