Page 1 of 5

Posted: Thu Apr 04, 2002 5:50 pm
by JayP
My program is being rejected by the judge, but I have not been able to find any test cases which cause it to give the wrong output. Can anyone think of some good input to test my program with?

Thanks :smile:

Posted: Fri Apr 05, 2002 1:53 am
by paulhryu
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)

Posted: Sat Apr 13, 2002 11:27 pm
by C8H10N4O2
Don't forget that the scent is cumulative. Never reset it. The scent is also on the last location of the robot (the last valid grid point), not the hole itself.

Output limit exceeded

Posted: Mon Apr 29, 2002 3:14 pm
by Deimos
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

sorry i thought i was posting on the problem 118 thread...

Posted: Mon Apr 29, 2002 3:17 pm
by Deimos
this is problem 118

Re: Output limit exceeded

Posted: Tue Apr 30, 2002 12:43 pm
by fpnc
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).
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.

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,

thanks for your help

Posted: Tue Apr 30, 2002 12:53 pm
by Deimos
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

Posted: Tue Apr 30, 2002 1:03 pm
by Stefan Pochmann
Fernando, can you explain why you can't recommend his input code? This is the way I always did it (well, without the '\n').

Posted: Tue Apr 30, 2002 1:10 pm
by judge
Stefan 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').
Well, maybe I shouldn't have said that :-?

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!!! :P

Posted: Tue Apr 30, 2002 8:06 pm
by C8H10N4O2
I always do [cpp]while(scanf("%d%d",&A,&B)!=EOF)[/cpp].

Posted: Wed May 01, 2002 4:56 am
by Stefan Pochmann
Nah, in C++ it should look like this:
[cpp]
while( cin >> a >> b ){ ... }
[/cpp]
Only situation where I don't do this is if input speed is crucial. C++ input sucks big time. I think my "Babelfish" solution from the last was too slow mostly because of that.

Posted: Wed May 01, 2002 1:00 pm
by C8H10N4O2
scanf is the paradigm of all input routines. I wish someone would take the time and implement format strings for streams:)

Posted: Tue May 14, 2002 2:29 pm
by cyfra
Hi!

Don't forget that you only have to delete this order when your robot get out of grid...

Don't delete next orders (if they are Ok for example turning because it have the influence on the answer)...

I hope It will help :)

Posted: Wed Jun 05, 2002 7:50 pm
by Betovsky
same prob here...
i have the scente working, ingoring commando too

using the sample input (has the LOSt thing and ignoring command)
on the prob it works great but on the judge ives wrong anser :(

118 Help!!!

Posted: Sat Jul 13, 2002 10:06 pm
by Subeen
I don't understand why my prog. got W.A. :(
Can someone help me with some inputs & outputs of this program?