MikeMirzayanov's blog

By MikeMirzayanov, 13 years ago, translation, In English

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

  1. 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.

  2. The system of conducting contests has two interface languages available: Russian and English. The contestants can switch between these two languages.

  3. A round continues for 2 hours, unless the information about the round states other duration time.

  4. Contestants are given 5 problems to solve, unless the information about the round states another number of problems.

  5. Problem statements are available in two languages: Russian and English

  6. Statements of all problems become available to read at the moment the round starts.

  7. Before the contest begins, all registered contestants are randomly split into rooms. Each room contains about 40 contestants.

Questions

  1. 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.

  2. 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'.

  3. The contest jury can answer the given question in an arbitrary text form.

  4. 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.

  5. 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

  1. 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
  2. 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.
  3. 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.

  4. 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

  1. 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
  2. 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.

  3. 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).

  4. If a compilation error occurs, than the contestant gets the judging result as 'Compilation error' and the compilation log.

  5. The size of the file with the source code shouldn't exceed 64 kilobytes.

  6. 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

  1. During the contest the solutions are judged on a small number of tests called pretests.

  2. The result of judging the solution on the pretests are displayed to the contestant right after the judging.

  3. 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.

  4. All problems indicate the maximum time a program can take to work on one test and the maximum memory that can be consumed.

  5. Judging is performed by consecutively running the program on each test.

  6. 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)
  1. 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.

  2. 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.

  3. The solution of one problem can be submitted multiple times.

  4. The solution that passes all pretests is considered the contestant's verified solution for this problem.

  5. 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.

  6. 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

  1. A contestant can lock any of his pre-solved problems. That means that the contestant loses the right to submit solutions for this problem.

  2. 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.

  3. A contestant gets 100 points for a successful hack and a penalty of 50 points for an unsuccessful hack.

  4. 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
  5. 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

  1. During the round the contestants are allowed to use any books and personal notes as well as a code written beforehand by you personally.

  2. 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.

  3. It is allowed to use any sources of information on the Internet (but it is forbidden to copy-paste somebody else's code).

  4. 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.

  5. 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).

  6. 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.

  7. 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.

  8. 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.

  9. 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

  1. 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.

  2. All intermediate results are unofficial.

System Testing and Final Standings

  1. After a contest is over, the results of the contestants' solutions' judging on the main set of tests are published.

  2. 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.
  3. A problem is considered solved by the contestant if the contestant's solution passed all tests from the main set of tests.

  4. A solved problem brings to the contestant the score, equal to the pre-score of his solution for this problem.

  5. A contestant's result is the sum of points for all problems he has solved plus points for hacks.

  6. 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.

  7. The judging is performed on computers Core 2 Duo E6750, 2.66 Ghz, 3Gb of memory.

Intellectual property

  1. 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.

  2. 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.

  3. 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.

  • Vote: I like it
  • +17
  • Vote: I do not like it

| Write comment?
»
13 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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)

  • »
    »
    13 years ago, # ^ |
      Vote: I like it +10 Vote: I do not like it

    You can not download another user solution.

  • »
    »
    13 years ago, # ^ |
      Vote: I like it +12 Vote: I do not like it

    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.

    • »
      »
      »
      13 years ago, # ^ |
        Vote: I like it -8 Vote: I do not like it

      It's cheating — why?

      • »
        »
        »
        »
        13 years ago, # ^ |
          Vote: I like it +12 Vote: I do not like it

        Common sence — otherwise it would be copyable

        • »
          »
          »
          »
          »
          13 years ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          If I write a GreaseMonkey script that helps me with re-typing a solution, will it be bad?

          • »
            »
            »
            »
            »
            »
            13 years ago, # ^ |
              Vote: I like it +11 Vote: I do not like it

            I think retyping of solution is not desired either — but it in any case should be mentioned in the rules

            • »
              »
              »
              »
              »
              »
              »
              13 years ago, # ^ |
              Rev. 3   Vote: I like it +8 Vote: I do not like it

              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).

      • »
        »
        »
        »
        7 years ago, # ^ |
          Vote: I like it +6 Vote: I do not like it

        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 ...

        • »
          »
          »
          »
          »
          7 years ago, # ^ |
            Vote: I like it -10 Vote: I do not like it

          But why? In Educationals hackers can download submissions.

»
13 years ago, # |
Rev. 2   Vote: I like it -8 Vote: I do not like it

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.

»
10 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Why does GNU C have "-fno-asm" flag, but GNU C++ doesn't?

»
9 years ago, # |
  Vote: I like it 0 Vote: I do not like it

I've read all notifications and rules above, ok, i'll take part in the contests. come on everyone.

»
8 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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!

»
7 years ago, # |
Rev. 2   Vote: I like it +13 Vote: I do not like it

In response to AIM Round 4 problem B, I'd like to ask whether the following construct would be viewed as a forbidden obfuscation.

std::mt19937 RNG{(long long)(std::hash<std::string>()({"randomStringLiteralOfLength>1000charactersThanNooneWillRetypeDuringContest"}))};

Of course, I would change the random string after I use it, so that no-one can calculate my seed in advance.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +18 Vote: I do not like it

    Another interesting question is what if this string contains tab and spaces instead

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Has this ever been clarified? Has anybody used such a technique these past few years?

»
7 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can I submit My code after the contest is over?

I want to check my code when I finally work it out.

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    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.

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

How can I hold a round in Codeforces?

»
6 years ago, # |
  Vote: I like it 0 Vote: I do not like it

If my first code is accepted but the second one is not, will the system run the first or the second code?

  • »
    »
    23 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    The last code which is Accepted will be run. So, the first code will be run.

»
5 years ago, # |
  Vote: I like it +8 Vote: I do not like it

each minute decreases the problem's value: the value decreases by X/250 points per minute (where X is a problem's initial value)

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.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

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?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    Not at all... Your rating doesn't vary until and unless you submit a solution for a problem during the contest.

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

What does Penalty mean in the contest?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

if i dont make any submissio in codeforces contest will that be evaluated??

  • »
    »
    5 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    No, registration for contest doesn't count as you attending contest until and unless you have atlest one submission (right or wrong)

    • »
      »
      »
      4 years ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      what if I have seen the questions but not submitted yet?

»
5 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Will the unsuccessful hacks be in the system tests?

»
5 years ago, # |
  Vote: I like it -6 Vote: I do not like it

Does CF deducts points for the first test case if it's wrong?

»
5 years ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

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?

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Commenting, so that anyone might answer this

  • »
    »
    5 years ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    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.

    • »
      »
      »
      5 years ago, # ^ |
        Vote: I like it +5 Vote: I do not like it

      Can you please explain me why i am getting idleness limit exceeded on this code?

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Can I see pretests after the contest. I just want to know what was going wrong.

»
3 years ago, # |
  Vote: I like it +1 Vote: I do not like it

Is there any negative markings? Can anyone score less than 0 points?

  • »
    »
    3 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    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.

»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

For the section "Questions" point 4, I suggest to:

  • add a word "meet" between "doesn't" and "the requirements"
  • move the word "either" forward, placing it between "that" and "the question"

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."

»
3 years ago, # |
  Vote: I like it -18 Vote: I do not like it

can we view the question(doubt) that we have asked during the time of contest??

»
2 years ago, # |
  Vote: I like it +3 Vote: I do not like it

my solution has passed all pretests, does it mean it is accepted or not ?? Someone please help , I am in a running contest now.

»
2 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

No one replied!

»
18 months ago, # |
  Vote: I like it 0 Vote: I do not like it

What does "but it is forbidden to copy-paste somebody else's code" means?

»
6 months ago, # |
  Vote: I like it 0 Vote: I do not like it

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?