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:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, kotlin, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.