An interesting subsequenceProblem code: C5 |
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.
Input
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.
Output
One number k, the length of the longest possible common subsequence that is increasing, followed by exactly k space-separated integers containing any exemplary sequence of this length.
Example
For the input:
5 2 3 1 4 0 6 10 3 4 1 0 0the unique correct answer is:
2 3 4
| Date: | 2009-04-20 |
| Time limit: | 3s |
| Source limit: | 50000 |
| Languages: | C C99 strict C++ PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp HASK CAML CLPS PRLG WSPC BF ICK TEXT |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.

Fetching successful submissions

the output of this prblm is not clear. i cant understand.
There is a discussion of the problem here: http://blog.codechef.com/2009/05/19/211/
My solution is giving correct results for seqs i give, but throwing 'wrong answers' here. I didn't go with the algo given on the discussion page.
Admin: is it possible to put some of your test cases/sequences here?
I'm reading input from four lines:
line-1: count of seq1 numbers,
line-2: integers for seq1, separated by one space
line-3: count of seq2 numbers,
line-4: integers for seq2, separated by one space
Output is:
line-1: count of result seq
line-2: integers of seq, in increasing order, with no duplicates
Please let me me know if anything is not correct. Thanks.
@praveen. The solutions for this problem are available. You can take any of the accepted solutions and test them yourself.
Thanks Admin.
But i dont see any successful solution here!!
Also, i'm more interested in having seqs for which my solution is throwing wrong results. Seeing other solutions is good, but having own solution working is better :). When the solutions are public, i'm sure the problem seqs can also be public. Thanks.
http://blog.codechef.com/2009/05/11/winners-of-may-challenge-test-cases/ :) Hope this helps.
Thanks a lot admin, for sharing seqs. My solution is passing 8 out of 12 seqs, and failing for other 4. However, few things to note:
1:- the C5_xx.out files contain only the result seq length, and not the actual seq numbers after that, whereas the problem example given above asks to print seq number also, which will result in "wrong answer" always, if you match solution output and the .out file.. 2:- I analyzed one failed scenario: C5_3.in. I found that the max common seq itself is of length 64 (set aside the "strict increasing" condition) then how can the final seq length be 84? Any hint or final seq numbers will be of great help, while i'm analyzing other 3 failed ones :). Thanks again.
The problem statement has been edited. Please check it out again.
Thanks for modifying problem statement.
Are you looking into testcase#3 (C5_3.in)?
As of now, it has been removed. We will look into it and if it is correct, will replace it and rejudge the submissions.
Do we hav 2 check the sequence,so that we realize the general trend of it's growth n compare all the possible valuse in the sequence??
Pls Lemme know!!
Your question is rather vague.
Hi, I am new here. Just a
A huge number of problems
A huge number of problems throughout all contests worldwide have space separated inputs on various lines, you're not going to get them to change that :P All languages can do some things and not others; Java has BigIntegers which makes programs involve them easier for example. You should be able to easily split a line on whitespace with split functions that come with whatever language you use.
As for input, the problem statement tells you what input you will receive. If it tells you something, you shouldn't assume what it tells you is wrong! You'll never receive any input that doesn't match what it says the input will be like.
Thanks for reply Stephen. So
Dear Admin, 'all
Hey Everyone! I coded the n^2
Hey Everyone!
I coded the n^2 solution and it gives the right answer for all official cases used in the contest but when submitting it gives WA.
So any help is appreciated :)
Thanks in advance!
@ALL: My solution gives
@ALL:
My solution gives correct answer...but codechef judge gives out WA...plz do check and help......Hmm can anyone one pointout the mistake.....
http://www.codechef.com/viewsolution/490595
thnx in advace...