Page 1 of 2

11760 - Brother Arif, Please feed us!

Posted: Sat Jan 16, 2010 7:32 pm
by durjay
code removed after accepted.

thank all.

11760(brother arif please feed us!) Wrong Answer

Posted: Sat Jan 16, 2010 8:01 pm
by Magual
hi,
code removed after being accepted thanks all . its been fun :D ok i m going to try another one ! :D

Re: 11760(brother arif please feed us!) Runtime error.

Posted: Sat Jan 16, 2010 8:38 pm
by Magual
hi ,
i m not much good at programming (specially pointers create problems in my head ) so i am having a bit problems in understanding your code I cant specify the problem..
but i can give an advice .. :D
well in the programming Challenges Book by Fred B. Schneider it says something about pointers since you are using pointers as arrays that maybe the problem
Runtime Error (RE) — Your program failed during execution due to a segmentation
fault, floating point exception, or similar problem. Its dying message will
be sent back to you. Check for invalid pointer references or division by zero.
see thats why i hate pointers! :D

Re: 11760(brother arif please feed us!) Runtime error.

Posted: Sat Jan 16, 2010 11:07 pm
by Taman
In this problem i got runtime error all time. but i do not understand why this is?please help me.
Well, i have not read your full code, but what i have found is, you have used a two dimensional array to keep track of the 2d grid. But the grid size may be 10000*10000 for this problem; I am afraid pointer or array can't keep so large memsize. That should be a cause of getting RTE.
Tips:
1. Think how you can avoid a 2d array/pointer for this problem;)
2. Though I haven't read the full code, I don't know whether you've done it or not. Always keep the track that your code does not exceed the boundary of the grid, like going to a cell (-1,-1) or (row, col)etc. . ..
Hope it helps. . .:)

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Sun Jan 17, 2010 3:50 pm
by lgarcia
Check this.

Input:

Code: Select all

5 5 1
4 4
0 0
5 5 2
1 1
3 3
2 2
0 0 0
Output:

Code: Select all

Case 1: Escaped again! More 2D grid problems!
Case 2: Escaped again! More 2D grid problems!

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Sun Jan 17, 2010 6:36 pm
by durjay
I think u not check when arif point is [0,0];
because on that time the position will be negative value.
I also face same problem.

I think now it will be accepted!!!!!!!!!

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Sun Jan 17, 2010 10:34 pm
by Magual
thanx to both of u for replying
and durjay well I am happy ,ur code got accepted ..but no my program dont have that (0,0) problem believe me , i already saw that one comming in my algorithm if Arif is at any corner his 2 of 4 posibilities of escaping become false , i m checking if a-1,a+1 ,b-1 or b+1 are lesser or greater then total column or rows (where 'a' is Arif's row and 'b' is his column number)
after so many WA i think maybe i have not understood the problem correctly. correct me if i m wrong here is what i think is going on if the input is

Code: Select all


5 5 1
4 4
0 0
5 5 2
1 1
3 3
2 2
0 0 0
so in first case
case #1

Code: Select all

     0    1    2     3   4
    ---  ---  ---  ---  ---   
0 |  A |    |    |    |    |
    ---  ---  ---  ---  ---   
1 |     |    |    |    |    | 
    ---  ---  ---  ---  ---   
2 |     |    |    |    |    |
    ---  ---  ---  ---  ---   
3 |     |    |    |    |    |
    ---  ---  ---  ---  ---   
4 |     |    |    |    | P |
    ---  ---  ---  ---  ---   
and

case #2

Code: Select all

      0   1    2    3    4
    ---  ---  ---  ---  ---   
0 |     |    |    |    |    |
    ---  ---  ---  ---  ---   
1 |     | P |    |    |    | 
    ---  ---  ---  ---  ---   
2 |     |    | A |    |    |
    ---  ---  ---  ---  ---   
3 |     |    |    | P |    |
    ---  ---  ---  ---  ---   
4 |     |    |    |    |    |
    ---  ---  ---  ---  ---   
where 'P' is one of the catcher , problemsetters and 'A' is Arif
ok according to lgarcia's input and output in the second case it says
Escaped again! More 2D grid problems!
in second case i m confused how does Arif escape when all four of his escaping possibilities are blocked

ok let me read the problem again .. i am missing something from the problem arn't I?

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Sun Jan 17, 2010 11:23 pm
by Magual
YES! off course its says in the problem
Brother Arif, standing on one of these cells, can move to one of the four adjacent cells just once or he may not move at all.

I was only checking the 4 adjacent blocks but not his current position
there are no 4 blocks to be cheked there are 5 ..
Alot thanks to you both couldnt have currected it without you I got accepted now
well It was first online contest that i ever participated ..and that was the only problem that i tried in that contest due to such a silly mistake i coudnt even get 1 accepted in the contest .. :( (*Snif* ...*Snif*) I am such a lousy problem solver !!

BTW: should i delete my code ? because it looks like whoever get there code corrected ..delete there code from the forum

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Mon Jan 18, 2010 1:46 am
by lgarcia
That was the problem (the two of them). I could say it directly, but people here don't let it be so easy. By the way, you have to keep trying, I needed several months to get one accepted and I have ~350 problems accepted by now.

And yes, you should delete the code after you got it accepted.

pls help me why i got wa

Posted: Sat Jan 30, 2010 2:51 pm
by nayimsust
this my code

Code: Select all

#include <stdio.h>
int main()
{
    long row,col,man,set[2050][4],r,c,t=0,mat[6][4],i,n,temp,j;
    while(scanf("%ld %ld %ld",&row,&col,&man)==3 && ( row !=0 || col !=0 || man!=0) )
    {
        for(i=1;i<=man;++i)
            scanf("%ld %ld",&set[i][1],&set[i][2]);

        scanf("%ld %ld",&r,&c);

        mat[1][1]=r;  mat[1][2]=c;
        n=1;
        if(r+1<row)
        {
            mat[++n][1]=r+1;mat[n][2]=c;
        }
        if(r-1>=0)
        {
            mat[++n][1]=r-1;mat[n][2]=c;
        }
        if(c+1<col)
        {
            mat[++n][1]=r;mat[n][2]=c+1;
        }
        if(c-1>=0)
        {
            mat[++n][1]=r;mat[n][2]=c-1;
        }

        for(i=1;i<=n;++i)
            for(j=1;j<=man;++j)
                if(set[j][1]==mat[i][1] || set[j][2]==mat[i][2])
                    mat[i][3]=1;
        temp=0;
        for(i=1;i<=n;++i)
            if(mat[i][3]==0)
                temp=1;

        if(temp==1)
            printf("Case %ld: Escaped again! More 2D grid problems!\n",++t);
        else
            printf("Case %ld: Party time! Let's find a restaurant!\n",++t);

        for(i=1;i<=n;++i)
            mat[i][3]=0;

    }
    return 0;
}

Re: 11760(brother arif please feed us!) Wrong Answer

Posted: Sat Jan 30, 2010 4:39 pm
by bm_anas
hi nayimsust, i checked your code.just use memset or initialize ur mat[][] variable before your while loop and u will be ok.
And try to do simple codes. :D :D

Re: 11760 - Brother Arif, Please feed us!

Posted: Tue Dec 02, 2014 12:51 am
by Shahidul.CSE
Hi, I am getting WA with my code.
Please anybody give me some input for which my code fails to give correct output...

Re: 11760 - Brother Arif, Please feed us!

Posted: Tue Dec 02, 2014 9:32 pm
by brianfry713
Don't read from a file.

Re: 11760 - Brother Arif, Please feed us!

Posted: Wed Dec 03, 2014 6:34 am
by Shahidul.CSE
getting WA.

Code: Select all

code removed after Accepted !!

Re: 11760 - Brother Arif, Please feed us!

Posted: Thu Dec 04, 2014 1:02 am
by brianfry713
Try running your code on the sample input.
Did you mean to include strings.h instead of string.h?