Sigsev error "Labyrinth"



I am getting sigseev error don’t know the reason please check my code

Qstn is easy so code is self explanatory though i have made detail comment.If one does not understand my code please comment i will write my whole algorithm in detail(as code might look dirty).

Thank you

Here, Take this.

1 Like

The reason for SIGSEGV is stack overflow. Recursive function olx has 5 parameters and 4 local variables, all of them are 64 bit and recursion can be quite deep. Merge x1, x2, x3 and x4 into one local variable, make r and c global and it should work.

1 Like

Rather than just giving a code, explain what you have done and also explain what the user was doing wrong. Just giving them the correct code without any explanation is of no use as they may not understand it.

@arun_as Thanks for your comment and downvote :frowning:

As far as my code is concerned I have replaced gc() in nil96’s code with cin which was causing the runtime error. Rest of it is same. So I think it won’t be a problem for nil96 to understand the difference.

You may ask nil96 to explain his approach or understand it yourself.

@rajeevkgprk, provide your explanation with your answer, not as a comment, edit it. BTW, I wasn’t the one who down-voted, I just explained why you got a down-vote.

Thank you @azukun

Thanks @rajeevkgprk and @arun_as for help

I am sorry for not explaining the code.I will further apologize as my algorithm was wrong too.This was a question of Tree diameter which i have implemented wrong as simple traversal(wrong algo)(my moving left,right,up,down).I am getting TLE now and trying my best to Submit the problem.