Rat chases its cheese - Recursion

https://hack.codingblocks.com/contests/c/537/570

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

Testcase 1 and 2 giving wrong answer

Hi Tarun, Please consider the corner cases for the problem. For example:

// Input
5 4
OXOO
OOOX
XOXO
XOOX
XXOO

// Expected Output
No Path Found

// Your Output
1 0 0 0
1 1 0 0
0 1 0 0
0 1 1 0
0 0 1 1

Hope this helps :slight_smile:

I don’t understand. Why would it show “No path found” when clearly there exists one. This sample case is given in the problem itself and according to it my output is correct. So what’s wrong with it ?

Hi Tarun, my apologies for the last one. But pls check your output for:

// Input
5 4
OOOO
XXXO
XXXO
XXXO
XXOO

// Expected Output
1 1 1 1
0 0 0 1
0 0 0 1
0 0 0 1

// Your Output
1 1 1 1
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1
1 1 1 1
0 0 0 1
0 0 0 1
0 0 0 1
0 0 0 1

Tip: Try solving from (n,m) instead of (0,0).

Hope this helps :slight_smile:

1 Like