Robota and Paths Problem

Sir, why am i getting the wrong answer on codechef.
Solution-https://ide.codingblocks.com/s/72277

Hi
check my code here

https://ide.codingblocks.com/s/72318

can you define your dp a little ?

and don’t forget to handle corner case

if(v[1][1]==-1||v[m][n]==-1)
{
cout<<“0\n”;
return 0;
}

Sir i have added some comments to my code. I have seen code of many other coders. But not able to find the error. I have cross checked by printing the dp matrix too. Please check it again . Reply ASAP.
Solution–https://ide.codingblocks.com/s/72277

your initialization of grid is wrong,
coz, in the 1st and 1st col the after getting -1 you are leaving the -1 after them in same line as -1 and many box will use this -1, so your initalization is going wrong,

see in code before taking that box to count i’m checking if it is -1 or not.

your corrected code https://www.codechef.com/viewsolution/24243290

see the the initialization grid[1][1]=1
and corner cases in main

1 Like

Thank You very much, sir, for your attention. Finally, I got it because of you.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like