This is a detailed and formal version of the Codeforces contest rules. If you just want to learn the rules, we recommend that you first read the post Codeforces Contests. The organizers may slightly modify the rules for specific rounds, then this information is contained in the announcement of the round. The following rules should be regarded as default rules.
General information about a round
You need to register to participate in a round. The registration opens six hours before the start of the contest and closes 5 minutes before it, unless the information about the round states otherwise.
The system of conducting contests has two interface languages available: Russian and English. The contestants can switch between these two languages.
A round continues for 2 hours, unless the information about the round states other duration time.
Contestants are given 5 problems to solve, unless the information about the round states another number of problems.
Problem statements are available in two languages: Russian and English
Statements of all problems become available to read at the moment the round starts.
Before the contest begins, all registered contestants are randomly split into rooms. Each room contains about 40 contestants.
Questions
During a contest the contestants can ask questions to the contest jury via the system. The questions may concern mistakes, ambiguous spots and inaccuracies in the statement.
A question must be asked in one of two languages: Russian or English. The question must be clear and written in a correct language. Otherwise, the jury preserves the right not to consider the question and answer 'no comments'.
The contest jury can answer the given question in an arbitrary text form.
The answer
No comments
means that the question either doesn't the requirements listed in point 2 or the answer to the question is in the statement or in the contest rules.An answer to a question is only available to the contestant who has asked it apart from the cases when the contest jury decides that the question is important for all contestants. In this case the jury can make the question and the answer to it available to all contestants.
Problem Solution
A problem solution is a program written in one of the following programming languages (different problems can be solved in different programming languages, the list of languages can be widened):
- С/С++
- Delphi/Pascal
- Java
- С#
- Python
- Ruby
- PHP
- OCaml
- Haskell
- Perl
- Scala
- D
- Go
Requirements to the solutions:
- The full program should be contained in a single file.
- If the problem statement doesn't specify the names of input or output, you must read the data from the standard input and write it to the standard output.
- You are forbidden to work with the Net.
- You are forbidden to perform input-output operations except for opening, closing, reading and writing files and standard streams given in the problem statements to perform input-output.
- You are forbidden to run other programs and create processes.
- You are forbidden to modify files or directories' permissions in the file system.
- You are forbidden to work with directories other than the current one.
- You are forbidden to work with the operating system registry.
- You are forbidden to create and use GUI elements (windows, dialogs etc.)
- You are forbidden to work with external devices.
- You are forbidden to perform any other actions that can in any manner destabilize the judging process.
After a contestant solves a problem, he submits the solution via the contest system interface and continues working on other problems. After the system receives and judges a solution, it immediately responses by displaying the result of judging the solution.
A contestant can see the results of judging of his solutions on the corresponding tab of the contest system. During a contest a contestant can see the results of only his solutions' judging.
Compiling solutions
As a contestant submits a solution, he chooses a compiler that the judging system should use as it compiles the program. The judging system uses the following compilers for judging (the jury has the right to add other compilers at its discretion or replace the compiler's versions with the newer ones):
- MinGW GNU C++ 4
- MinGW GNU C 4
- MS VS C++ 2010
- Free Pascal 2
- Delphi 7
- C# Mono 2
- Java 6, 7
- Ruby 1
- Python 2
- PHP 5
- Haskell GHC 6
- Objective Caml 3
- Scala 2
- Perl 5
- MS C# .NET 4
The contest organizers are not responsible for problems caused by the compiler's version in the judging system not matching the compiler's version used by the contestant as he was writing the program. To partially avoid such problems, there is an option to run a contestant's code on the server's side. To run the code, the contestant should submit the program and the input to the server. After a while the judging system will display the result of the program's execution and the output.
Solutions are compiled and run under Windows OS. Line breaks are set by a couple of symbols #13#10. A file's or an input's last line should end with a line break (right before the end of the file).
If a compilation error occurs, than the contestant gets the judging result as 'Compilation error' and the compilation log.
The size of the file with the source code shouldn't exceed 64 kilobytes.
The judging system uses command line compilers to compile solutions. The compiler command lines for different compilers are given in the table:
Compiler | compilation (execution) command line |
---|---|
GNU C++ 4 | g++.exe -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -lm -s -x c++ -Wl,--stack=268435456 -O2 -o %name%.exe %1 |
GNU C 4 | gcc.exe -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -fno-asm -lm -s -Wl,--stack=268435456 -O2 -o %name%.exe %1 |
GNU C++ 4 (C++0x) | g++.exe -static -fno-optimize-sibling-calls -fno-strict-aliasing -DONLINE_JUDGE -lm -s -x c++ -Wl,--stack=268435456 -O2 -std=c++0x -D__USE_MINGW_ANSI_STDIO=0 -o %name%.exe %1 |
MS VS C++ 2010 | cl /W4 /F268435456 /EHsc /O2 /DONLINE_JUDGE %1 |
Free Pascal 2 | fpc -n -O2 -Xs -Sgic -viwn -dONLINE_JUDGE -Cs67107839 -Mdelphi -XS %1 -o%name%.exe |
Delphi 7 | dcc32 -Q -$M1048576,67107839 -DONLINE_JUDGE -cc %1 |
C# Mono 2 | dmcs -define:ONLINE_JUDGE -o+ -out:%name% %1 |
Java 6,7 | javac -cp ".;*" %1, java.exe -Djava.security.manager -Djava.security.policy=java.policy -javaagent:invokeagent.jar -Xmx512M -Xss64M -DONLINE_JUDGE=true -Duser.language=en -Duser.region=US -Duser.variant=US -jar %s |
Ruby 1 | ruby.exe -c %1 |
Python 2 | python -c "compile(open('%1').read(), '%1', 'exec')" |
PHP 5 | php.exe -l %1 |
Haskell GHC 6 | ghc --make -O -o %name% %1 |
OCaml 3 | ocamlopt nums.cmxa str.cmxa -pp camlp4o -unsafe -o %name%.exe-ocaml %1 |
Scala 2 | См. Java |
Perl | perl.exe %s |
D | dmd -L/STACK:268435456 -version=ONLINE_JUDGE -O %s |
Go | go build %1 |
Judging Solutions
During the contest the solutions are judged on a small number of tests called pretests.
The result of judging the solution on the pretests are displayed to the contestant right after the judging.
Each test is represented by the input for the contestant's program. The limits for the input contained in the test are indicated in the problem statement.
All problems indicate the maximum time a program can take to work on one test and the maximum memory that can be consumed.
Judging is performed by consecutively running the program on each test.
The test is considered passed if running the program terminated with the return code 0, the process fit into the given time and memory limits and besides, the program printed the correct answer to the given test. The table below gives the most frequent verdicts of possible errors.
Judgement Verdict | Description |
---|---|
Memory limit exceeded | The program tries to consume more memory than is indicated in the problem statement |
Time limit exceeded | The program hadn't terminated in time indicated in the problem statement |
Runtime error | The program terminated with a non-zero return code (possible reasons: array out of bound error, division by zero, stack overflow, incorrect pointers usage, etc) |
Wrong answer | Wrong answer |
Idleness limit exceeded | The program didn't use the CPU time for considerable time |
Denial of judgement | The solution was impossible to run, perhaps, due to a judging error. The most probable cause is an error in the program (for example, using extra large arrays) |
If the solution passed all pretests, the contestant is displayed the result that says
Pretests passed
. Otherwise, the contestant is displayed the judging result as the number of the first pretest that failed the judging and the judging system verdict.If the result of the judging is
Compilation Error
,Denial of judgement
(or similar) or if the solution didn't pass the first pretest, then this solution won't be considered in calculating results.The solution of one problem can be submitted multiple times.
The solution that passes all pretests is considered the contestant's verified solution for this problem.
If a contestant submits several times a problem's solution that passes all pretests, then the last solution is considered as the contestant's verified solution for this problem. All other solutions will be considered as unsuccessful attempts.
If a contestant's solution passes all pretests, the problem is considered pre-solved by the contestant and the system calculates the contestant's preliminary points for the given problem. The points are calculated by the following scheme:
- each minute decreases the problem's value: the value decreases by X/250 points per minute (where X is a problem's initial value), for example, a problem with the initial value of 500 points gets 2 points cheaper every minute;
- the number of points a contestant gets for a problem equals the current value of the problem in points minus penalty;
- the penalty is determined as the number of this contestant's previous solutions for this problem, multiplied by 50 points;
- a contestant can't earn less points than 30% of the initial problem value.
Hacks
A contestant can lock any of his pre-solved problems. That means that the contestant loses the right to submit solutions for this problem.
After the contestant locks a problem, he gets the right to view the original codes of submitted solutions of other contestants for this problem that share the same room with him. Having viewed another person's code, the contestant can suggest a test on which, as he thinks, the given solution will fail. This procedure will be further called a solution's hack. A test can be given manually or using a generator program that writes the test to the standard output. The system automatically validates the test to satisfy problem statement constraints. If it doesn't, the contestant is notified about it and the hack attempt is ignored. If the test satisfies the indicated constraints, then the solution runs on the offered test. If the solution doesn't pass the test, then the hack is considered successful, otherwise it is considered unsuccessful. A hack attempt is also ignored if by the given moment the hacked solution is not the contestants' last verified solution of the problem. For example, this might be the case if somebody already hacked the given solution before or the hacked contestant has resubmitted the solution.
A contestant gets 100 points for a successful hack and a penalty of 50 points for an unsuccessful hack.
If a contestant's solution is successfully hacked, then happens the following:
- he problem isn't considered pre-solved by this contestant anymore
- his preliminary points for this problem are reset to 0
- the test from the hack is added to this problems' pretest set for the given contestant
If a contestant locked a problem, but had the solution hacked, then he preserves the right to hack other people's solutions for this problem.
Can-do's and Can't-do's
During the round the contestants are allowed to use any books and personal notes as well as a code written beforehand by you personally.
It is forbidden to use somebody else's code in the solution.You may use third-party prewritten code with some restrictions, read carefully about it.It is allowed to use any sources of information on the Internet (but it is forbidden to copy-paste somebody else's code).
It is forbidden to obfuscate the solution code as well as create obstacles for its reading and understanding. That is, it is forbidden to use any special techniques aimed at making the code difficult to read and understand the principle of its work.
The contestants are forbidden to talk about subjects, related to the problems, with anybody, including other contestants. It is only allowed to ask questions to the jury via the system (see the 'Questions' section).
The organizers of the contests have the right to monitor the contestants' honesty in behavior using different methods and disqualify the contestant if violations are found.
All programs submitted by the contestants for judging, should be aimed at solving the problem and not at violating rules or destabilizing the judging system. A contestant who deliberately attempts to destabilize the judging system, will be disqualified.
Attempting to digitally extract other contestant's code during the hacking is considered cheating. You may not use any technical/digital tools to obtain other contestant's code, including (but not limited) OCR, traffic capture, browsers plugins and so on. The only allowed method to analyze other contestant's solution is reading it in a hacking window. However it is allowed to manually retype the solution or it's parts to run it locally.
Any violation of these rules, rules from the FAQ section, rules from the contest announcement or rules that were accepted during the registration will lead to penalty provisions, including disqualification.
Standings
During the contest the current results' table is available to the contestants. The table shows the current place of each contestant. The table also contains the information about the hacks and the history of submissions of each contestant.
All intermediate results are unofficial.
System Testing and Final Standings
After a contest is over, the results of the contestants' solutions' judging on the main set of tests are published.
The main test set is used to judge verified solutions, i.e., the solutions that meet all these criteria:
- passed all pretests;
- are the last submitted solutions of each contestant for each problem;
- haven't been hacked.
A problem is considered solved by the contestant if the contestant's solution passed all tests from the main set of tests.
A solved problem brings to the contestant the score, equal to the pre-score of his solution for this problem.
A contestant's result is the sum of points for all problems he has solved plus points for hacks.
In the final results' table the contestants are listed in the order or the results' decreasing. If two or more contestants have the same result, they share the same place.
The judging is performed on computers Core 2 Duo E6750, 2.66 Ghz, 3Gb of memory.
Intellectual property
The rules below are used each time if for a particular round there are no separate rules. Competitors retain ownership of all intellectual and industrial property rights (including moral rights) in and to Submissions.
As a condition of submission, Competitor grants Codeforces, its subsidiaries, agents and partner companies, a perpetual, irrevocable, worldwide, royalty-free, and non-exclusive license to use, reproduce, adapt, modify, publish, distribute, publicly perform, create a derivative work from, and publicly display the Submission.
Contestants provide submissions on an "as is" basis, without warranties or conditions of any kind, either express or implied, including, without limitation, any warranties or conditions of title, non-infringement, merchantability, or fitness for a particular purpose.
Is it legal if I do following scenario?:
pass pretests and lock my solution
download another user solution
compile it (without reading source)
run some tests on my machine
hack solution (if for any test outputs are different)
You can not download another user solution.
AFAIK, you are not allowed to screen his solution and get it's text using some programs — it's cheating. but, i think, you can print this solution by yourself and test it.
It's cheating — why?
Common sence — otherwise it would be copyable
If I write a GreaseMonkey script that helps me with re-typing a solution, will it be bad?
I think retyping of solution is not desired either — but it in any case should be mentioned in the rules
I think that retyping can not be forbidden because sometimes you need to check some language features like (-1 % 2 == -1).
Or round(0.5) ==0, round(1.5) == 2 (like Delphi).
Maybe it was added later, but:
Attempting to digitally extract other contestant's code during the hacking is considered cheating. You may not use any technical/digital tools to obtain other contestant's code, including (but not limited) OCR, traffic capture, browsers plugins and so on. The only allowed method to analyze other contestant's solution is reading it in a hacking window. However it is allowed to manually retype the solution or it's parts to run it locally.
Point 8 in Can-do's and Can't-do's ...
But why? In Educationals hackers can download submissions.
Mike, here is a feature request: put the hacking details at the bottom of a submission if it was hacked. It will be very useful and more handy, thanks.
Why does GNU C have "-fno-asm" flag, but GNU C++ doesn't?
I've read all notifications and rules above, ok, i'll take part in the contests. come on everyone.
you didn't :)
Hello. I usually write the code and compile it on Linux (using gcc). Is there any way of checking that if I try to compile the file with the Windows GCC compiler, it won't fail? Thanks!
You can try http://codeforces.me/problemset/customtest — it will compile & run the code using codeforces platform.
Thanks! If the program works fine using the codeforces plataform, it will work for the problem tests of the contest?
In response to AIM Round 4 problem B, I'd like to ask whether the following construct would be viewed as a forbidden obfuscation.
Of course, I would change the random string after I use it, so that no-one can calculate my seed in advance.
That's one creative idea :D
I don't think it's forbidden. "That is, it is forbidden to use any special techniques aimed at making the code difficult to read and understand the principle of its work." Your code will be easy to read, and they can understand it, so it's not obfuscating.
Another interesting question is what if this string contains tab and spaces instead
Has this ever been clarified? Has anybody used such a technique these past few years?
Can I submit My code after the contest is over?
I want to check my code when I finally work it out.
You can use virtual participation to take part in past contest, as close as possible to participation on time. Or you can simply submit your codes in the problemset.
How can I hold a round in Codeforces?
read here https://codeforces.me/blog/entry/49569
Thanks.
If my first code is accepted but the second one is not, will the system run the first or the second code?
The last code which is Accepted will be run. So, the first code will be run.
In this 150-minute contest the penalty per minute is only
120/150 * (total score)/250
, not(total score)/250
.Is that still the case? If so, please edit the rule accordingly.
If a user is registered for a rated contest, but unable to make it (i.e. never looked at the problems), does that impact rating?
Not at all... Your rating doesn't vary until and unless you submit a solution for a problem during the contest.
Thanks
What does Penalty mean in the contest?
Did you find out yet lol
if i dont make any submissio in codeforces contest will that be evaluated??
No, registration for contest doesn't count as you attending contest until and unless you have atlest one submission (right or wrong)
what if I have seen the questions but not submitted yet?
Will the unsuccessful hacks be in the system tests?
Does CF deducts points for the first test case if it's wrong?
No
For the Idleness Limit Exceeded, what does one mean by The program didn't use the CPU time for considerable time? Also, when do programs tend to give Idleness Limit Exceeded, and how can it be avoided?
Commenting, so that anyone might answer this
I can give one such situation where you will get Idleness Limit Exceeded. It happened to me some contests back.
Suppose the query is like this- We will output some indices of the array and we will get the index i among these such that Arr[i] is maximum among all the indices for which we queried for.
Now suppose we queried like this-
3 1 2
Here first integer 3 denotes that we will output 3 indices for which we want to query. But as you can see after this only two indices have been printed which are 1,2. In this case, you will get an Idleness Limit Exceeded.
Can you please explain me why i am getting idleness limit exceeded on this code?
I think the problem is that you are not flushing the output. After outputting anything, use fflush(stdout) in cpp.
Read this blog:Guide for interactive problems
Hope this helps!
This problem is not an interactive one as far as i know. Or is it an interactive problem?
Can I see pretests after the contest. I just want to know what was going wrong.
Is there any negative markings? Can anyone score less than 0 points?
You don't get penalty points for problems you don't end up solving. Also, see: "a contestant can't earn less points than 30% of the initial problem value."
You can earn negative score, but pretty much only on purpose — by solving a problem, locking it, and making many bad hacks on other's solutions.
For the section "Questions" point 4, I suggest to:
in order to clarify its meaning, resulting in this clearer statement instead:
"The answer "No comments" means that either the question doesn't meet the requirements listed in point 2 or the answer to the question is in the statement or in the contest rules."
can we view the question(doubt) that we have asked during the time of contest??
my solution has passed all pretests, does it mean it is accepted or not ?? Someone please help , I am in a running contest now.
No one replied!
What does "but it is forbidden to copy-paste somebody else's code" means?
If you register for a contest, but fail to appear, and then participate in the virtual contest the next day, are you rated for it in Codeforces?
no