• Welcome to Computer Association of SIUE - Forums.
 

ACM Online Judge

Started by Ryan Lintker, 2003-01-14T17:42:08-06:00 (Tuesday)

Previous topic - Next topic

Ryan Lintker

Hey folks.  I just wanted to start a thread about the online judging system for ACM practice problems and Dr. Yu's numerous homework assignments.  I think that this system has value, but it takes a little getting used to in order to master the I/O involved in getting a program to work for the judge.

I'm just looking for hints, tips, tricks, etc. for turning programs written as we are taught into programs that the Online Judge looks favorably upon.

I'm having a heck of a time getting the judge to agree that my current program (CS 438, #537) is correct.  I say it is, the judge sees otherwise.  I'm using getline to get my input data for the program.  Is that a bad idea?  Does anybody have any tricky input data that could throw my results off?
"You can't always get what you want,
 but if you try sometime, you just might find,
you get what you need" - The Rolling Stones

Guest

If i were you i wouldn't use getline. I'd only use printf and scanf. Like the following:

scanf("%[^\n]",&line);

This will continue to read in data until a \n is detected.

I've only done a couple of these but every time i used something other then printf or scanf the judge freaked out.

This should work for data entered at the keyboard, i'm not sure exactly how the online judge grades the programs, but if they do something like blah.exe < data.txt (correct me if thats the wrong syntax, i forgot) I think that should work. That is, if getline is even your problem  :-P

William Grim

The ACM online judge DOES recognize trailing whitespace!!!

That got me one time.

Also, I'm planning to check out Refactoring (by a guy I don't remember) that talks about some great ways to test your own programs for flaws.

Might wanna check that out as well.  Sorry I can't give more info on that :-/
William Grim
IT Associate, Morgan Stanley

Ryan Lintker

Well, I found out that getline is ok, although I used gets in the program that got accepted.  My resource on string functions didn't tell me exactly how all of those functions behave.  One really surprised me and I am still confused.  I found some obscure test data on a bulletin board online which produced the odd results.  Good luck to those still working on it.
"You can't always get what you want,
 but if you try sometime, you just might find,
you get what you need" - The Rolling Stones