Robot Collect points

Problem Link:
https://online.codingblocks.com/app/player/115374/content/73646/5239/code-challenge

Code Link:

I am not getting what is meant by making the cells from -1 to 0. Can you please check my code and tell me the required modifications?

@mgfags
The problem link is not accessible to me but as you have mentioned you are taking about Robot Collect Points problems.
Making all cells from -1 to 0 just means the change the values present at (i,j) in that subgrid then find the answer using recursion as you are doing.

So, This problem is just about traversing all the possibilities 2-D matrix with the help of recursion.
But one modification here you can do is, you can modify any 5*5 subgrid such that change values from -1 to 0 and others remains same.
Here the width is fixed i.e. 5.
So, For eg if h=7, then you can modify only these subgrids,where h is from 1-5, 2-6, 3-7.

So before traversing the matrix using recursion just modify all the possibile subgrids one by one.

If we take N as 5, that is maximum height as 5, then we can only get one sub matrix of 5*5, that is 1-5, so, we can convert convert from -1 to 0 in this submatrix only. Maximum points are coming as 3 .

Initially the matrix is
0 0 -1 1 0
0 0 0 1 0
0 -1 -1 -1 0
-1 0 1 0 0
0 1 -1 0 0

after changing all -1 to 0 it will be:-
0 0 0 1 0
0 0 0 1 0
0 0 0 0 0
0 0 1 0 0
0 1 0 0 0
this will be the path, so answer will be 4.

Thanks for helping.I am getting correct answer now.

1 Like