Page 1 of 3

### 11561 - Getting Gold

Posted: Mon Dec 22, 2008 7:53 am
Hi, I'm getting W.A in this problem. Please give some I/O.

Code: Select all

``````Cut ...
``````

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:22 am

Code: Select all

``````               if(maze[i-1][j]=='T' || maze[i][j-1]=='T' || maze[i+1][j]=='T' || maze[i][j+1]=='T')
{
maze[i][j] = 0;
} ``````
Probably you are pointing out of maze..

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:30 am
I started value of i and j from 1.

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:42 am
Do you think maze[i+1][j] is always indexing within your maze?
When i = n, then it is indexing maze[n+1][j], but your maze is [1][1] to [n][m], right?

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:49 am
but my maze size is 53 (maze[53][53]) larger than given limit (3 to 50). First I set all element of maze to 0 (using memset).
So when maze[i+1][j] is called, this dosen't exceed maze. Could please explain ?

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 9:08 am

Code: Select all

``````      else if(maze[i][j-1]=='L')
{
_count++;
``````
Is this correct?

### Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 9:15 am
sorry, i don't understand.
Here I indicated 'L' as the position where there is a gold beside a trap.
So, after getting gold it increments it's counter and return's back to avoid trap.

### Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 1:03 pm
whatever, I updated my code using scanf instead of cin. But still WA. Someone please give some I/O.

Code: Select all

``````Cut ...
``````

### Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 3:13 pm
Consider this case

Code: Select all

``````4 4
####
#TP#
#GG#
####``````
Output should be 0(zero).

### Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 7:07 pm
Thank's a lot emotional blind. That was the case I caught.
Now rank 12 in this problem.

### Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 7:36 pm
have fun and keep posting

### Re: 11561 - Getting Gold

Posted: Wed Dec 24, 2008 10:53 am

Code: Select all

``removed``

### Re: 11561 - Getting Gold

Posted: Tue Dec 30, 2008 12:33 pm
Try the cases.

Input:

Code: Select all

``````8 4
########
#.T.TGT#
#.G..P.#
########
7 8
#######
#P...T#
#...G.#
#G.T..#
#.....#
#G..T.#
#.....#
#######
``````
Output:

Code: Select all

``````1
2``````
Hope these help.

### Re: 11561 - Getting Gold

Posted: Sun Jan 11, 2009 11:53 am
I edited my code, but still WA!!!!

Code: Select all

``removed``

### Re: 11561 - Getting Gold

Posted: Sun Jan 11, 2009 8:11 pm
Try the case.

Input:

Code: Select all

``````6 5
######
#TG..#
#TG.G#
#TGPG#
######
``````
Output:

Code: Select all

``5``