There is something missing in my code which leads to wrong answer on codechef platform
My code link-https://ide.codingblocks.com/s/342488
Sir/mam i am not able to think test case on which my code fails
anyone from Teaching assistant why not answer my question?
for(int i=1;i<=n;i++)
{
if(dp[1][i]==0)
{
dp[1][i]=1;
}
else
{
dp[1][i]=0;
}
}
See here let us say there are 9 cols and 5th is blocked, there is no way then to reach 6th 7th and 8th as well
but in your code, only 5th will remain blocked because it has a value !=0 while others still have 0 and hence they will be shown as 1 path which is wrong
same with the rows’ loop as well
after fixing this, simply do dp[i][j] = dp[i-1][j] + dp[i][j-1] in the final loop
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.