This section explains how you should write your program. Since the competition is automatically controlled by scripts, it is important that your program works exactly according to these rules.
Sending your program
To enter the contest, you must write a program that is able to
You can submit the sourcecode of your program on this website.
The source code must consist of one single file.
The maximum allowed size of the source file is
Input and output
Your program reads input from standard input (normally "the keyboard") and writes output to standard output (normally "the screen"). Your program is started once at the beginning of a game and keeps running until the end of the game.
You should strictly follow the dialogue described in the game rules. Each element of input or output is on a line by itself.
You may assume that all input to your program is completely correct.
For debugging, your program may write messages to standard error. Those mesages will become available to you, and only you, on the game result page. However there is a limit to the amount of characters that will be logged (approximately 10000 characters), so you need to use it sparingly.
You may write your program in Pascal, C, C++, Java, Python or Haskell. The table below shows which compiler and configuration we are using.
C and C++
Programs written in C or C++ are compiled with GCC, and linked with the standard math library.
You can use
In C++ it is also possible to use
Programs written in Pascal are compiled with FreePascal in TurboPascal mode.
FreePascal is a lot like Turbo Pascal, but it is more powerful.
You can make an array of a few megabytes size without problems.
Please note that the types
You can use
Using units in your program is not recommended. They will not help you very much and may cause problems when your program runs in the competition system. It is not possible to use units you have written yourself, since your source code must consist of a single file. Especially the CRT unit will cause problems. Do not use the CRT unit.Java
Programs written in Java are compiled and run with OpenJDK.
You can use the object
It is possible to make more than one class for your program, but
you will have to put the source for all classes in a single .java
file (the compiler will produce multiple .class files anyway).
When you do this, you should not declare your classes
When submitting your Java program on the website, don't forget
to enter the exact name of the main class
of your program (the class which contains the
One must read input by using the
As far as we know, there is no way to print to the error stream.Python
Programs written in Python are run with the Python interpreter.
You can use
You can use the standard Python modules (
Note that Python programs are typically slower than programs in C, Pascal or Java.
Your program is allowed to use at most 5 seconds per game. We measure only the time that your own program spends to select a move, not the time that your opponent spends to select a move. If your program exceeds the time limit, it loses the game and receives a penalty for irregular loss of a game.
There is no time limit per move, only the time limit per game. So your program could use 4 seconds for the first move, but then it would have to do the rest of the game in 1 second.
Remember that the CodeCup systems are 3.10GHz. If your computer at home is slower or faster, you will have to be careful. It is always a good thing to play a game at home exactly as it was played on the CodeCup system. You can see how much time had been used by your program.
To keep the contest fair, some things are not allowed: