SIGSEV in Twin Robots when using DP, AC using Recursion.

I was solving this problem: CodeChef: Practical coding for everyone

It looked like a simple DP and I implemented it here: CodeChef: Practical coding for everyone
However, it gives me a Segmentation Fault.

I tried to debug it and found that the problem is with this line:

int curr_value = grid[i][j] + grid[j][N - i - 1];

When I set it to 0, it gives me WA as expected.

Surprisingly, when I switched to Recursion + Memoization, it gives me an AC.
This is the solution using Recursion: CodeChef: Practical coding for everyone

Can someone tell me why the first solution isn’t working?

Declare those , arrays global ,and as [2500].I too was earlier getting segmentation fault . I dont know if rest has error i not.
http://www.codechef.com/viewsolution/6048142

1 Like

Thanks! That worked somehow!

1 Like