Computer Association of SIUE - Forums

CAOS Forums => Questions and Answers => Topic started by: Ryan Lintker on 2003-01-14T17:42:08-06:00 (Tuesday)

Title: ACM Online Judge
Post by: Ryan Lintker on 2003-01-14T17:42:08-06:00 (Tuesday)
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?
Title: Re: ACM Online Judge
Post by: Guest on 2003-01-14T19:17:25-06:00 (Tuesday)
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  (//www.billzor.com)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
Title: Re: ACM Online Judge
Post by: William Grim on 2003-01-14T21:32:37-06:00 (Tuesday)
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 :-/
Title: Re: ACM Online Judge
Post by: Ryan Lintker on 2003-01-21T22:30:34-06:00 (Tuesday)
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.