lowest common subsequence - TLE

this code of mine gives TLE, i made a lot of changes to avoid it but wasnt successful,
plz help,

problem link - TLCS Problem - CodeChef
my code - MijXTp - Online C++0x Compiler & Debugging Tool - Ideone.com

Your solution gives TLE because you are performing about 10^9 operations in the worst case and that would take more than 5 seconds, which is the time limit for this problem.

Note that this a Challenge Problem, so you can optimize your solution to get a better relative score as compared to others for the given time limit.

For example, refer this solution which got 1.000 points or this solution which got 0.916 points.

1 Like

Can you please post the question link here?

yes, ur answer makes sense,
but for all cases requiring greater than 6*10^5 operations we dont calculate the LCS.i cant convince my self why it should not give WA in those cases,…
thanks for reply :slight_smile:

Well, honestly, I am confused about that too. Don’t know why this is a Challenge problem. The ones who got 1.000 points just printed ‘N’ when time exceeded 4.9 seconds or similar. So, I hope someone else can give a better answer to our doubts.