394. Alphacode spoj - SIGABRT, algo is Dp, so does my code have stack/memory overflow??

its a classical dp prob on spoj:

prob link : http://ideone.com/usArDk
heres my code : http://ideone.com/usArDk

i have little knowledge about SIGABRT, so i checked my code for infinite loops and memory overflows, and corrected two mistakes, but still i get the same error when i submit it on spoj…

thanx for ur time…:slight_smile:

You copied the code link twice :wink:

The reason for SIGABRT here is not because of consuming too much memory. The faulty statement is on line 23 in your code: “if(10*(s.at(len-2) -‘0’)” here, suppose value of len for some case is 1, then the statement will refer to s.at(-1) which causes the SIGABRT error here. Correct it by putting a condition for len<2

1 Like