Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register
北京大学《ACM-ICPC竞赛训练》暑期课面向全球招生。容量有限,报名从速!

Frequently Asked Questions Answered

POJ Administrative Staff

Composing solutions

Common guidelines for composing solutions

The judge system challenges you with thousands of programming problems which demand diverse ideas and techniques to solve. Nevertheless, you must write the solutions in accordance with certain common guidelines so that they are judged as intended.

Guideline 1 Do exactly what the problems demand. A mistake made by some newcomers is to print some friendly-looking prompt messages such as “Please input an integer” which the problems do not ask for. Another example of violating this guideline is to leave debug information in the output. Our judge system is automated. There is no human involvement in judging the solutions. Neither the administrators nor the developers will read any output by the solutions in normal circumstances. Hence, unrequested prompt messages are virtually useless. Worse still, undesired output may mess with the jugding process, which in all probability will lead to rejection of the solution, even though it is logically correct.

Guideline 2 Access only the standard input, the standard output and the memory. Your solution must always read the input data from the standard input and write the output data to the standard output. The only location that your solution can utilize for storage is the memory. Access to other resources such as disks and the file system is denied by the judge system. Any such attempt results in undefined behavior.

Guideline 3 Write standard-conforming code. We promote the use of standard-conforming code. Certain compilers offer vendor-specific features beyond language standards. We have made efforts to disable these features to advocate standard-compliant programming practices. Solutions using these features are likely to fail compilation.

Language-specific requirements and examples

The judge system currently services solutions written in C, C++, Pascal, Java and Fortran. Details about the compilers used and supported language standards are listed in the table below. A sample solution to Problem 1000 in each language is available in the Appendix.

Language Compiler(s) Standard Remark(s)
C MS VC++ 2008 Express (“C”) and MinGW GCC 4.4.0 (“GCC”) C99
  • The macro ONLINE_JUDGE is defined.
  • The C99 implementation of GCC 4.4.0 is not considered feature-complete. In particular, support for variable-length arrays and intrinsic complex and imaginary types is labeled “broken”.
C++ MS VC++ 2008 Express (“C++”) and MinGW GCC 4.4.0 (“G++”) C++98
  • The macro ONLINE_JUDGE is defined.
  • Currently there is no plan to enable the experimental C++0x features before the new C++ standard is officially published and relatively well-supported.
Java JDK 6 (“Java”)
  • The system property ONLINE_JUDGE is set.
  • You should write a class named Main with public or package visibility. This Main class should contain the entry-point main method.
Pascal FreePascal 2.2.0 (“Pascal”) FreePascal dialect
  • The macro ONLINE_JUDGE is defined.
Fortran MinGW GCC 4.4.0 (“Fortran”) Fortran 95

The judging process

Access keys in the solution submission page

Access key Page element
Alt+L Language drop-down list
Alt+P Problem ID field
Alt+S Submit button
Alt+U User ID field
(available only after you have logged in)

The judging process in a nutshell

The judging process starts with the judge system saving a submitted solution to a source file named Main with an appropriate extension. Next a designated compiler is invoked to compile the saved solution. If compilation succeeds, the judge system proceeds to run the solution on each test case available. The judging process is designed to reject-fast—once the judge system has spotted evidence to reject the solution, it exits the judging process and responds immediately.

Verdicts of the judge system

Verdict Abbreviation Indication
Accepted AC The solution has produced output that the judge system or a checker program (commonly referred to as a special judge) accepts as correct.
Presentation Error PE The solution has produced output that is correct in content but incorrect in format.
Time Limit Exceeded TLE The solution has run for longer time than permitted. This means either the time spent on all test cases exceeds the overall limit or that spent on a single test case exceeds the per-case limit. Note that time limits for solutions in Java are tripled. These solutions are also allowed an extra 110 ms for each test case.
Memory Limit Exceeded MLE The solution has consumed more memory than permitted.
Wrong Answer WA The solution has not produced the desired output.
Runtime Error RE The solution has caused an unhandled exception (as defined by the runtime environment) during execution.
Output Limit Exceeded OLE The solution has produced excessive output.
Compile Error CE The solution cannot be compiled into any program runnable by the judge system.
System Error The judge system has failed to run the solution.
Validator Error The checker program has exhibited abnormal behavior while validating the output produced by the solution.

Other questions

ISO C-conformant printf format specifiers

Prior to the compiler upgrade in May 2009, we serviced C and C++ submissions using GCC 3.4.2. That version of GCC relies on the old MS VC++ 6 runtime library, which does not support the %lld and %llu specifiers for signed and unsigned long long types but allows the standard-incompliant %lf and %lg specifiers for floating-point types. The new GCC 4.4.0 comes with its own ISO C-conformant implementation of the printf function. Now you can use %lld and %llu with either C/C++ compiler, but %lf and %lg only work with MS VC++ 2008 Express. As a rule of thumb, you should always use the %f and %g specifiers instead for floating-point types.

Unanswered questions

If you have questions unanswered in this page, feel free to post them on the web board or write to the administrators.

Appendix

Sample solutions to Problem 1000

Language Sample solution to Problem 1000
C
#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%d%d", &a, &b);
    printf("%d", a + b);
    return 0;
}
C++
#include <iostream>

using namespace std;

int main(void) {
    int a, b;
    cin >> a >> b;
    cout << a + b;
    return 0;
}
Java
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        System.out.println(a + b);
    }
}
Pascal
program p1000(Input, Output);
var
    a, b: integer;

begin
    read(a, b);
    write(a + b)
end.
Fortran
      PROGRAM P1000

      IMPLICIT NONE
      INTEGER :: A, B

      READ(*,*) A, B
      WRITE(*, '(I0)') A + B

      END PROGRAM P1000

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator