Getting Started
So you want to do programming contests but don't know where to start? Well, it seems you do....since you're, well, here.
Contests
Contests come in many shapes and sizes. Here are some of them
ICPC
The international collegiate programming contests is the largest contest for college programmers. It consists of two levels: regionals and world finals. We compete in the mid-atlantic regional. Generally the top two to three teams from each region are invited to world finals (though they can't be from the same school). World finals are often held in exotic places such as Phuket and Banf.
Contest Environment
For these contests you have teams of three individuals, but just ONE computer. There are generally 8-13 problems to solve in the 5 hours. Problems will always describe some sort of problem whose output will vary based on some input. While you are given some sample input and output, whether your algorithm is deemed "correct" is based on secret input that you are NOT given. Instead, you must submit your code, where a "judge" (i.e. some server running somewhere) will run your code against the secret input and compare your output with the correct secret output. Only if you get the secret output exactly correct will your submission get correct. Submissions must be in Java, C, or C++.
Input and Output
You must write a standalone program (it will have a "main" method) which reads from standard input and writes to standard output.
Ranking
Teams who solve the MOST problems in the 5 hours are the winners. Tie breaking is done by your total penalty time, which is calculated as follows
- For any problem you solved, the number of minutes that have elapsed since the start of the contest when you solved it are added
- For any problem you solved, 20 minutes are added for each INCORRECT submission BEFORE you got the problem solved correctly
Codeforces
Codeforces is one of the best regular contests to help prepare you for ICPC. Their contests are run almost exactly the same as ICPC, but with individuals instead of teams. Keep an eye out for them, and know that you often have to register before the round starts. You will start in division 2, and will be promoted to division 1 when your ranking is high enough.
==Topcoder Topcoder is another hoster of regular contests. Their Single Round Matches (SRMs) are quick ways to practice.
Contest Environment
For these contests, you launch their "arena" and assuming you have registered for the contest, are placed in a room with ~20 other coders. When the contest starts, each of the three problems will be visible. When you open one, you will provided with a text editor. There is nothing stopping you, however, from using whatever editor you choose and copying the code in. Once you put the code in, you can compile and run a few example test cases to see if they pass, and finally submit. UNLIKE ICPC, however, you will not get your result. For now Topcoder will ASSUME your answer is correct and award you the points.
Challenge Phase
Once the coding phase has ended, you enter the challenge phase. Here you can look at the solutions of other people in your room. If you think they made a mistake, you can "challenge" their solution by providing an input you think their code will get wrong. You get points if you are correct, or lose them if you are not. Only one person can successfully challenge an incorrect solution, so be quick!
System Test
Lastly, the "judge" will run all the solutions against secret test cases, removing points which were awarded if the solution was deemed incorrect.
Ranking
Problems are each worth different point values (generally 250, 500 and 1000). When you FIRST open a problem, the clock starts ticking, and the more time you take to solve that problem is deducted from the amount of points it is worth. So if you end up taking a long time to solve the first problem, you might only get 150 points. At the end of the contest, your points from solutions (which passed system test) and from challenges are added, and the person with the most wins.
Input and Output
You are generally provided with a method signature which you must implement. You will not need a "main" function for these, as your code will just be included by some other program. The input will be the method parameters, and the output will be the return.
Starting to Practice
If you have NEVER solved a problem before, you're probably going to want to start with Kevin's trivial set. There you will find problems (which come from REAL CONTESTS) which will help you get your feet wet. You will need a login, so ask kevin for one.
Writing your First Solution
The first thing I do when I solve ANY problem (literally...any problem) is start with my template. It looks like this
import java.util.*;
public class a {
Scanner in=new Scanner(System.in);
public static void main(String[] args) {
new a().go();
}
private void go() {
// read input
// do stuff
// print output
}
}
Input and Output
We have a great tutorial on Input and Output. It will be the first thing y