Spoj: LCS2

help
spoj
string
substring

#1

problem : LCS2
Can someone please help me in optimizing my solution (giving TLE). I am trying this for the last 4 days.
Any other method for solving this using Suffix Trees will also be helpful.


Why this code is giving NZEC error