Our problem set contains a large number of problems from programming contests of various difficulty. The automatic online judge can instantly check your solutions for correctness. This section is a step-by-step instruction on how to work with the online judge.
1. Choose the problem
To find the list of the problems, visit Problem set link, and choose a volume or a category. Choose an interesting problem. For those who are new here, be sure to start with the problems 1000. A+B Problem and 1001. Reverse Root. Once you have chosen a problem, proceed to solving it.
2. Solve the problem and submit the solution for judging
The problem solution is a single source code of a program written in one of the available programming languages.
Here is an example solution for the problem 1000. A+B Problem in Pascal. The task is to read two integers and print their sum:
var
a, b, sum: integer;
begin
read(a, b);
sum := a + b;
writeln(sum);
end.
The online judge will be able to judge your solution if it meets the following requirements:
- The program must be a console application.
- Input data must be read from the standard input (input from the keyboard). Output data must be printed to the standard output (screen output).
- The program must print only the data that is required by the problem statement. The program must not print any prompts (“Enter N:”). The program must not wait for pressing a key at the end of execution.
Input data in the test cases always satisfy the constraints described in the problem statement. You don’t need to verify these constraints in your solutions.
Solutions are not allowed to:
- work with the file system;
- execute other programs and create new processes;
- create or manipulate any GUI resources (windows, dialog boxes, etc.);
- work with external devices (sound, printer, etc.);
- access the network.
To learn how to use a specific programming language, read one of the following sections:
Once you have written the solution and tested it on the samples from the problem statement, you can submit it for judging. To submit a solution you need the JUDGE_ID, which you can obtain by registering on the website.
3. The judge checks your solution
When you submit a solution you are redirected to the Judge status page, which has a list of recently submitted solutions. Yours should be among them.
The solution is judged automatically by successive executing it on a set of test cases, which is not available to solution authors and is the same for all solutions for this problem.
The solution is considered to be correct if it outputs correct answers for all test cases. The first test cases in the set are usually the same as the samples in the problem statement. If the correct answer is not received for some test case, the judging process stops, the test number and the type of the error are reported in the judgment results table. Some problems may have multiple correct answers for the same test case. In this case, the answer will be checked for correctness by a special checking program.
Each problem statement defines the maximum execution time and the amount of available memory for a single test case. If the program exceeds the time limit or allocates more memory for some test case, the test case is considered to be failed. The output of the program is not checked in this case. In some problems the time and memory limits might be quite challenging. Solving such problems in some of the available languages might be very difficult or even impossible.
The execution time is the CPU time of the process. To estimate the amount of memory used by the solution, the online judge takes the maximum amount of memory used by the process during its execution (peak working set) and decreases it by a constant (usually from 1 to 15 MB) equal to the minimum amount of memory that is needed for the programs in the selected language to run.
The judgement result can be one of the following:
- Accepted. The solution is accepted.
- Compilation error. Compilation of the program failed. The compilation report will be available for 15 minutes via the link on the Judge status page. Possible reasons: syntax error, wrong language selected.
- Wrong answer. The answer of the program is incorrect. In this case, only the test number is reported. The input data of this test case is not available, the solution author should find the cause of the error on their own. Possible reasons: error in the program, the algorithm is incorrect, the program outputs the answer to a file.
- Time limit exceeded. The program exceeded the time limit. The solution will be stopped as soon as the time limit is exceeded. Possible reasons: infinite loop; inefficient solution.
- Memory limit exceeded. The program exceeded the memory limit. The solution will be stopped once the limit is exceeded. Possible reasons: memory leak, inefficient solution.
- Output limit exceeded. The program exceeded the limit on the output size. This limit is set with a large margin and is usually not specified in the problem statement. Possible reasons: infinite loop; bug in the program.
- Idleness limit exceeded. The program was idle for a long period of time. Possible reasons: waiting for a key press at the end of the program; reading the input data after it has been read to the end.
- Runtime error. The program terminated with a runtime error. Possible reasons: non-zero exit code, division by zero, infinite recursion (error code “stack overflow”), insufficient array size or accessing unavailable memory (error code “access violation”). To avoid stack overflow use special directives that are described in sections devoted to specific programming languages.
- Restricted function. The program tried to perform an operation, which is considered unsafe for the online judge. Possible reasons: reading a file, accessing a network resource.
For example, if you get the judgment result “Wrong answer on test 3”, this means that your solution passed test cases 1 and 2 but gave an incorrect answer for test case 3.
Test cases |
Execution |
Output |
1-2 |
Within limitations |
Correct answer |
3 |
Within limitations |
Wrong answer |
4-N |
Not executed |
Not evaluated |
If you after that find and fix the error, resubmit the solution and get the judgment result “Time limit exceeded on test 10”, this means that you indeed fixed the error that was checked by test case 3. Now the solution passes all test cases from 1 to 9 but exceeds the time limit on test 10. It remains unknown if the answer that your program would print on this test case was correct.
Test cases |
Execution |
Output |
1-9 |
Within limitations |
Correct answer |
10 |
Time limit exceeded |
Not evaluated |
11-N |
Not executed |
Not evaluated |
The reported execution time and memory usage are the maximum values among all executed test cases. In the above examples, these are test cases 1-3 and 1-10 respectively. Note that the maximum time and the maximum memory values can be achieved in different test cases.
4. The problem is solved. What’s next?
Each problem has a solution rating. The solutions are ordered first by their execution time, then by date. Once your solution is accepted you can look through the rating and get the idea how efficient your solution really is.
You can always discuss a specific problem or a general online judge issue at the forum. If you found an error in the problem, write about this to the forum with a prefix “To admins” in the topic. If your solution was accepted but you still have a test that it doesn’t pass, please email this test to timus_support@acm.timus.ru with the topic “Weak tests in problem X”.