118 - Mutant Flatworld Explorers
Moderator: Board moderators
Well, this is a straightforward problem, I don't think there's too much room for error, but did you do the scent thing so that after one robot is lost, no other robot will ever go off at that point?
Just helping... post your code and maybe I can help. It shouldn't be too long or something's wrong. (Haha I rhymed)
Just helping... post your code and maybe I can help. It shouldn't be too long or something's wrong. (Haha I rhymed)
Output limit exceeded
here is my main function code:
well I know this one is a straight foward problem, but i just started on this site...
I think my problem is the EOF i dunno how to implement it. i tried several things but if I only get either worng answer cuz it will not enter the while, or Output limit exceeded when it does not get out (still don't get why i get that Output limit exceeded).
[c]while(scanf("%d %d %c\n%s",&x,&y,&o,&orders)==4)
{
lost=0;
for (i=0;i<strlen(orders);i++)
{
if (lost) break;else
switch(orders)
{
stuff to move and turn and mark where the robot fall of the grid.
}
}
printf("%d %d %c",x,y,o);if (lost) printf(" LOST\n"); else printf("\n");
}[/c]
Btw i also have probs to understand what happens on the corners, i mean if a robot goes off the grid on a corner should it be allowed to fall of in the other direcction it did not fall ? lets see, on the upper left corner a robot can fall heading North or East.
regards
D
well I know this one is a straight foward problem, but i just started on this site...
I think my problem is the EOF i dunno how to implement it. i tried several things but if I only get either worng answer cuz it will not enter the while, or Output limit exceeded when it does not get out (still don't get why i get that Output limit exceeded).
[c]while(scanf("%d %d %c\n%s",&x,&y,&o,&orders)==4)
{
lost=0;
for (i=0;i<strlen(orders);i++)
{
if (lost) break;else
switch(orders)
{
stuff to move and turn and mark where the robot fall of the grid.
}
}
printf("%d %d %c",x,y,o);if (lost) printf(" LOST\n"); else printf("\n");
}[/c]
Btw i also have probs to understand what happens on the corners, i mean if a robot goes off the grid on a corner should it be allowed to fall of in the other direcction it did not fall ? lets see, on the upper left corner a robot can fall heading North or East.
regards
D
sorry i thought i was posting on the problem 118 thread...
this is problem 118
Re: Output limit exceeded
In the 99% of the cases, Output Limit is done because your program enters an infinite loop, and usually it writes the same output once and another and another... In this case, I think it is related to your non-knowledge of managing EOF.Deimos wrote:I think my problem is the EOF i dunno how to implement it.
i tried several things but if I only get either worng answer cuz it will not enter the while, or Output limit exceeded when it does not get out (still don't get why i get that Output limit exceeded).
I can't recommend you to read the input in this way:
[c]while(scanf("%d %d %c\n%s",&x,&y,&o,&orders)==4)[/c]
Personally, I prefer this:
[c]while (!feof(stdin)) {
scanf(" %d %d %c ", &x, &y, &o);
scanf(" %s ", &orders);
/* ... process this entry ... */
}[/c]
You can assume that after every 2 numbers and a character you'll find a string, because the input file is valid (this is that you won't find any entry which does not adjust to the statement), so try to find out the EOF before reading a test case, and if we have not EOF, then read a test case and process it.
Also, please note the blank spaces before %d, after %c and before and after %s; with these, you'll skip blank spaces and "\n" so you won't have to bother about them anymore.
Hope this helps. Best regards,
Best regards,
Fernando N
Fernando N
thanks for your help
i finally got the correct answer, but i think the problem was my definitions of the arrays where i stored orders data and the scent.
Any how your way to get data seems more efficient and bug free
thanks
Any how your way to get data seems more efficient and bug free
thanks
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
Well, maybe I shouldn't have said thatStefan Pochmann wrote:Fernando, can you explain why you can't recommend his input code? This is the way I always did it (well, without the '\n').
First, I'm a Pascal programmer, not a C programmer, so I tend to do the things in the Pascal way. Related to that, I find the code I propose easier to trace in case of problems.
Second, I do NOT like seeing things like "\n" or even "\^[\n]" in a scanf sentence. Scanf is something "obscure" for me, so I prefer to use it in a simply way. I know that these kind of things should work, but I don't rely on them...
Third, in the last contest, one of my friends (and competitors ) had an Output Limit answer just because of the EOF matter, and it was solved by checking for EOF using feof.
I know that the EOF, and more generally, the way the input file is written, is a common source of problems. Because of that, I prefer to do things easier. 1 feof + 2 scanf is easier (to me) than 1 scanf with \n inside it.
But, I'm pretty sure that a C guru can demonstrate me the goodness of the scanf function, so I won't argue with anyone about this matter
P.S.: Pascal forever!!!
-
- A great helper
- Posts: 284
- Joined: Thu Feb 28, 2002 2:00 am
- Location: Germany
- Contact:
118 Help!!!
I don't understand why my prog. got W.A.
Can someone help me with some inputs & outputs of this program?
Can someone help me with some inputs & outputs of this program?