I was solving this problem: http://www.codechef.com/INPR1503/problems/TWINRO
It looked like a simple DP and I implemented it here: http://www.codechef.com/viewsolution/6048086
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: http://www.codechef.com/viewsolution/6048285
Can someone tell me why the first solution isn’t working?