An interesting subsequence
All submissions for this problem are available.
For two given sequences of integers, find the longest possible integer sequence which is a subsequence of both these sequences, and whose elements are integers in a (strictly) increasing order.
The first number is n (1 ≤ n ≤ 5000), the length of the first sequence.
The next n integers are elements of the first sequence.
The next is m (1 ≤ m ≤ 5000), the length of the second sequence.
The next m integers are elements of the second sequence.
On the first line, print a single number k, the length of the longest possible common subsequence that is increasing.
In the next line, print k space separated integers which is the answer. If there are multiple possible subsequences, any one would do.
For the input:
5 2 3 1 4 0 6 10 3 4 1 0 0
A correct answer is:
2 3 4
|Time Limit:||0.2 - 0.6 sec|
|Source Limit:||50000 Bytes|
|Languages:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, COB, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, kotlin, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, rust, SCALA, SCM chicken, SCM guile, SCM qobi, ST, swift, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.