11760 - Brother Arif, Please feed us!
Moderator: Board moderators
11760 - Brother Arif, Please feed us!
code removed after accepted.
thank all.
thank all.
Last edited by durjay on Sun Jan 17, 2010 6:39 pm, edited 2 times in total.
11760(brother arif please feed us!) Wrong Answer
hi,
code removed after being accepted thanks all . its been fun
ok i m going to try another one ! ![:D](./images/smilies/icon_biggrin.gif)
code removed after being accepted thanks all . its been fun
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
Last edited by Magual on Mon Jan 18, 2010 5:07 pm, edited 1 time in total.
Re: 11760(brother arif please feed us!) Runtime error.
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](./images/smilies/icon_biggrin.gif)
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![:D](./images/smilies/icon_biggrin.gif)
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](./images/smilies/icon_biggrin.gif)
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
see thats why i hate pointers!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.
![:D](./images/smilies/icon_biggrin.gif)
Re: 11760(brother arif please feed us!) Runtime error.
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.In this problem i got runtime error all time. but i do not understand why this is?please help me.
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. . .
![:)](./images/smilies/icon_smile.gif)
Re: 11760(brother arif please feed us!) Wrong Answer
Check this.
Input:
Output:
Input:
Code: Select all
5 5 1
4 4
0 0
5 5 2
1 1
3 3
2 2
0 0 0
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
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!!!!!!!!!
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
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
so in first case
case #1
and
case #2
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?
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
case #1
Code: Select all
0 1 2 3 4
--- --- --- --- ---
0 | A | | | | |
--- --- --- --- ---
1 | | | | | |
--- --- --- --- ---
2 | | | | | |
--- --- --- --- ---
3 | | | | | |
--- --- --- --- ---
4 | | | | | P |
--- --- --- --- ---
case #2
Code: Select all
0 1 2 3 4
--- --- --- --- ---
0 | | | | | |
--- --- --- --- ---
1 | | P | | | |
--- --- --- --- ---
2 | | | A | | |
--- --- --- --- ---
3 | | | | P | |
--- --- --- --- ---
4 | | | | | |
--- --- --- --- ---
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
YES! off course its says in the problem
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
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 ..
![:(](./images/smilies/icon_frown.gif)
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
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.
And yes, you should delete the code after you got it accepted.
pls help me why i got wa
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
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](./images/smilies/icon_biggrin.gif)
And try to do simple codes.
![:D](./images/smilies/icon_biggrin.gif)
![:D](./images/smilies/icon_biggrin.gif)
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11760 - Brother Arif, Please feed us!
Hi, I am getting WA with my code.
Please anybody give me some input for which my code fails to give correct output...
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
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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11760 - Brother Arif, Please feed us!
Don't read from a file.
Check input and AC output for thousands of problems on uDebug!
-
- Experienced poster
- Posts: 148
- Joined: Sun Jul 13, 2014 4:32 am
- Location: Rangpur, Bangladesh
Re: 11760 - Brother Arif, Please feed us!
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
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
-
- Guru
- Posts: 5947
- Joined: Thu Sep 01, 2011 9:09 am
- Location: San Jose, CA, USA
Re: 11760 - Brother Arif, Please feed us!
Try running your code on the sample input.
Did you mean to include strings.h instead of string.h?
Did you mean to include strings.h instead of string.h?
Check input and AC output for thousands of problems on uDebug!