views:

82

answers:

1

Robot judges suck! I've been accepted by UVA, only after removing the following chunks of code:

cin >> ntc;
/* extract newline from previous read */
char dummy(0);
cin.get(dummy);
assert( '\n'==dummy );
/* newline extract completes */

Replacing it with :

cin >> ntc;
getline( cin, inputN ); /* extract remaining '\n' */

Before replacement the honorable robot judge at UVA would verdict:

Your submission .... has failed with verdict Time limit exceeded.

Your program used more CPU time than what is allowed for this problem. That means that your algorithm is not fast enough or that it entered into an infinite loop.

After the replacement the program took 0.052 seconds to run!

  1. In what way could it be related with the replaced code?
  2. Is there any document on how does UVA robot judge differ from other compilers? So that I know what functions/methods are available on the online judge.

I use MinGW.

+3  A: 

Assert can't create an infinite loop.

My guess is that when assert triggered, a just-in-time debugging prompt was displayed by the OS ("An error has occurred in the program... [Debug] [Cancel]"). (Sorry, I'm not running Windows at the moment, so can't check the actual wording). Since noone was there to press either button and the process is not terminated until someone does, the robot thought the program was still running.

I think it's an error in the UVA setup. Just-in-time debugging has to be disabled.

atzz
can you tell anything about char dummy(0); declaration? I haven't seen anything like that before. Is it same as char dummy; ?
Sazzad
@TheMadman - that's effectively the same as `char dummy = 0;` or `char dummy = '\0';`.
Steve Townsend