Page 1 of 3

11561 - Getting Gold

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

Code: Select all

Cut ...
Thank's in advance.

Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:22 am
by emotional blind

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
by mukit
Could you please explain ?
I started value of i and j from 1.

Re: 11561 - Getting Gold

Posted: Mon Dec 22, 2008 8:42 am
by emotional blind
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
by mukit
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
by emotional blind

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
by mukit
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
by mukit
whatever, I updated my code using scanf instead of cin. But still WA. Someone please give some I/O.

Code: Select all

Cut ...
Thank's in advance.

Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 3:13 pm
by emotional blind
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
by mukit
Thank's a lot emotional blind. That was the case I caught. :D
Now rank 12 in this problem.

Re: 11561 - Getting Gold

Posted: Tue Dec 23, 2008 7:36 pm
by emotional blind
have fun and keep posting :)

Re: 11561 - Getting Gold

Posted: Wed Dec 24, 2008 10:53 am
by Obaida
Some one please help me I got WA!!!!

Code: Select all

removed

Re: 11561 - Getting Gold

Posted: Tue Dec 30, 2008 12:33 pm
by Jan
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
by Obaida
I edited my code, but still WA!!!!

Code: Select all

removed

Re: 11561 - Getting Gold

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

Input:

Code: Select all

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

Code: Select all

5