11760 - Brother Arif, Please feed us!

All about problems in Volume 117. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

durjay
New poster
Posts: 13
Joined: Tue Oct 06, 2009 5:09 pm
Location: ctg

11760 - Brother Arif, Please feed us!

Post by durjay »

code removed after accepted.

thank all.
Last edited by durjay on Sun Jan 17, 2010 6:39 pm, edited 2 times in total.
Magual
New poster
Posts: 4
Joined: Thu Jan 14, 2010 11:32 am

11760(brother arif please feed us!) Wrong Answer

Post by Magual »

hi,
code removed after being accepted thanks all . its been fun :D ok i m going to try another one ! :D
Last edited by Magual on Mon Jan 18, 2010 5:07 pm, edited 1 time in total.
Magual
New poster
Posts: 4
Joined: Thu Jan 14, 2010 11:32 am

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

Post 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
Taman
New poster
Posts: 32
Joined: Sun Oct 11, 2009 8:59 pm
Location: Southeast University

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

Post 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. . .:)
lgarcia
New poster
Posts: 16
Joined: Mon Sep 14, 2009 7:49 pm
Location: Venezuela

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

Post 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!
durjay
New poster
Posts: 13
Joined: Tue Oct 06, 2009 5:09 pm
Location: ctg

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

Post 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!!!!!!!!!
Magual
New poster
Posts: 4
Joined: Thu Jan 14, 2010 11:32 am

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

Post 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?
Magual
New poster
Posts: 4
Joined: Thu Jan 14, 2010 11:32 am

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

Post 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
lgarcia
New poster
Posts: 16
Joined: Mon Sep 14, 2009 7:49 pm
Location: Venezuela

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

Post 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.
nayimsust
New poster
Posts: 9
Joined: Wed Aug 27, 2008 6:50 pm

pls help me why i got wa

Post 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;
}
bm_anas
New poster
Posts: 10
Joined: Fri May 15, 2009 9:13 pm

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

Post 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
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 11760 - Brother Arif, Please feed us!

Post 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...
Last edited by Shahidul.CSE on Wed Dec 03, 2014 6:49 am, edited 3 times in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11760 - Brother Arif, Please feed us!

Post by brianfry713 »

Don't read from a file.
Check input and AC output for thousands of problems on uDebug!
Shahidul.CSE
Experienced poster
Posts: 148
Joined: Sun Jul 13, 2014 4:32 am
Location: Rangpur, Bangladesh

Re: 11760 - Brother Arif, Please feed us!

Post by Shahidul.CSE »

getting WA.

Code: Select all

code removed after Accepted !!
Last edited by Shahidul.CSE on Thu Dec 04, 2014 7:00 am, edited 1 time in total.
Md. Shahidul Islam
Dept. of CSE at Begum Rokeya University, Rangpur, Bangladesh
UVa id: http://uhunt.felix-halim.net/id/438420
My facebook account,
Email me: shahidul.cse.brur@gmail.com
brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 11760 - Brother Arif, Please feed us!

Post by brianfry713 »

Try running your code on the sample input.
Did you mean to include strings.h instead of string.h?
Check input and AC output for thousands of problems on uDebug!
Post Reply

Return to “Volume 117 (11700-11799)”