Getting Started with the ACM Archive
To get involved with the ACM competitions you will want to practice by solving lots of problems. The ACM archive allows you to submit solutions and get almost instantaneous feedback. (Ok, so it may take a few seconds).
Get registered:
- Go to http://livearchive.onlinejudge.org
- Click on the Register link and follow the instructions.
- When you are done, they will emai you an ID, which is currently a four digit number, and a suffix, currently two letters. Don't lose these! You will need both the ID and the suffix each time you submit a problem. The suffix is a form of security so that no one will submit problems, accidentally or not, under your id.
Things you should know
- The problem specs will always give you some sample input and corresponding output. Your program will be run against a test set consisting of a number of cases in addition to the ones shown in the spec. It is very likely that the the test set will have harder cases than those shown in the spec.
- No one will read your code! If defining a variable as global makes your code much easier, no one will be looking over your shoulder and criticizing your code. However, there are good reasons for writing good code as it is frequently easier to figure out what's wrong when your code doesn't work if you write it "neatly".
- Any programs you submit to the archive must never open any files. You only read from standard input and you only write to standard output.
- The only things that your program should write to standard output are the required results. If you go and output some prompt like, "Please enter the length, width and height: ", then the archive's testing program will assume that that is part of your answer and immediately say that you got the problem wrong.
- A common mistake is to think that you have to "save up" your answers to all of the test cases and only write them out after all the test cases are completed. This is wrong and just makes your coding a little more annoying. Typicaly after each test case you should output the necessary result. When you are testing your code, this may look a little odd as your input and output will be intermixed. Don't worry about that, When they run your code they are redirecting standard input to come from their test file and similarly redirecting standard output so that your results all go to another file. [If you don't understand that last sentence, don't worry about it.]
- To find a particular problem, click the search link on the archive home page and enter the problem's number in the Problem field. (However, to make life easy, I have provided links for the problems that mention below.)
- The goal is for your solution to be marked "Accepted". Sometimes instead you will get a "Presentation Error". This means that you probably had extra blanks at the end of the line, or too many or too few blank lines in your output. Occasionally the exact amount of "whitespace" allowed or required is not very clear in the problem specs, so I wouldn't worry too much. However, on the actual competitions, a presentation error still qualifies as wrong. Make sure that, at the least, every line ends in a newline character. Forgetting that is a common mistake.
- Everything in the output line is important! That includes case (upper or lower), punctuation, blanks, etc. More than once I have gotten "Wrong Answer" due to a spelling error or typo. It's a good idea to copy / paste from the actual problem statement into your code, rather than retyping the things that don't change.
Try the following problems:
There are hundreds of problems on the archive. Some are exceedingly difficult. Others are trivial. Below are a few problems that I suggest that you start out with. I will rank them with zero being absolutely trivial and higher numbers being harder. You may not agree with my rankings but at least it gives you someone's impression of how hard a problem is.
- 3077 - No Brainer. (rank: 0) This is truely a no brainer, but doing it and getting it accepted should ensure that you know how work with the archive.
- 2540 - The Hardest Problem Ever. (rank: 1). A little harder. Caesar Cypher. Note that the output they provide for the sample input has a few obvious typos. Don't worry. Their real test set is correct. That means if they say you got the wrong answer when you submit your solution, then you really did get the wrong answer.
- 2832 - A Contesting Decision. (rank: 1) This is handy to do just because it explains the scoring rules used in the actual ACM competitions.
- 2557 - The Drunk Jailer. (rank: 2). Many problems involve "simulating a process". This is perhaps the simplest of that sort. Any of you who did math team competitions in high school might recognize this problem. If you don't, be sure to look at the cell numbers that end up unlocked.
- 2866 - Candy Sharing Game. (rank: 2). Another reasonably straight-forward simulation task.
- 2286 - Microprocessor Simulation (rank: 3). I really like this one. If you are not at all familiar with the idea of machine language, you might be confused by the terminology. Other than that, this is pretty cool because you are actually simulating the workings of a very simple processor. (I should warn you that some students really dislike this one.) Oh, it doesn't mention it in the spec anywhere I can find, but be sure to initialize the "accumulators" to zero for each program you run. You'll know what I mean after you read the problem.
- 3502 - The mysterious X network. (rank 4). Find the shortest path.
- 3639 -
Prime Path. (rank 5). A problem involving searching. This time with wandering from one four-digit prime number to another.
- 3497 - Brainf*ck. (rank: 5). This is similar to the Microprocessor Simulation, but with some additional complications. Be warned that you may get your code to work reasonably on the examples, only to get "Time Limit Exceeded" when you sumbit your code.
Let me know if there are other problems that you think should be on this short list.
More ranked problems:
I'll be curious to get feedback on these rankings. Sometimes difficulty is just a matter of how long it takes us to see the solution. Other times it's a matter of turning it into working code. Note that it is even worth doing easy problems if you focus on doing them quickly and being sure to get them right the first time.
Rank 0
Rank 1
Rank 2
***** The archive has changed all of the links and I will have to go through fixing them one by one. I will move this message down as I fix each one *****
Rank 3
Rank 4
Rank 5
Rank 6