Our problem set contains a lot of problems from programming contests of various difficulty. The automatic online judge can instantly check your solution for correctness. This section is a step-by-step instruction on how to work with the online judge.
1. Choose the problem
To view the list of problems, visit Problem set link, and choose a volume or a category. Choose the appropriate 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 source code of a program written in one of the available programming languages.
Here is an example solution (in Pascal) for the problem 1000. A+B Problem, in which you asked to read two integers and print their sum:
a, b, sum: integer;
sum := a + b;
The online judge will be able to test 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 thefile 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 coded 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 site.
3. The judge tests 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 testing on a set of 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 to all the test cases. The first test cases in the set are often 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 program.
Each problem statement defines the maximum execution time and the amount of available memory for each 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 can be quite challenging. Solving such problems in some of the available languages may be very difficult or even impossible.
The online judge uses CPU time only to calculate the solution running time. To estimate the amount of memory used by the solution, the online judge calculates the maximum amount of memory used by the process during its execution (peak working set) decreased 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 judging result can be one of the following:
- Accepted. The solution is accepted.
- Compilation error. Compilation of the program failed. The compilation report will be accessible for 15 minutes via the link on Judge status page. Possible reasons: syntax error, wrong language specified.
- 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 because the solution author should find the cause of the error on his 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 this 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 not usually specified in the problem statement. Possible reasons: infinite loop; bug in the program.
- Idleness limit exceeded. The program is idle for a long period of time. Possible reasons: waiting for a keypress 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 unaddressable 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 operation unsafe for the automatic judge, for example, tried to read a file or tried to access a network resource.
For example, if you’ve received the “Wrong answer on test 3” judgment result, this means that your solution passed test cases 1 and 2 and printed an incorrect answer for test case 3. If you’ve fixed an error, resubmitted a solution and received the “Time limit exceeded on test 10” judgment result, this means that the fixed error indeed manifested itself on test case 3. Now the solution passes all test cases from 1 to 9 but exceeds the time limit on test 10. You can’t tell for sure if the answer that your program would print on this test case would be correct, as your program was terminated by the judge before it finished execution.
4. The problem is solved. What’s next?
Each problem has a rating of solutions. Solutions are ordered first by their running time, then by date. When your solution is accepted, you can look at this rating and estimate how efficient your solution is.
You can always discuss a specific problem or a general online judge issue at the forum. If you’ve found an error in the problem, write about this at the forum with a prefix “To admins” in the topic. If your solution is accepted, but you have a test case which breaks your solution, please email this test case to email@example.com.