Welcome to ZOJ
FAQ
Frequently Asked Questions

Q:What is the compiler the judge is using and what are the compiler options?
A:The online judge system is running on Linux. We are using GNU GCC/G++ for C/C++, Free Pascal for Pascal and Sun JDK 1.6 for Java. The compile options are:
C: gcc foo.c -o foo -ansi -fno-asm -O2 -Wall -lm --static -DONLINE_JUDGE
C++: g++ foo.c -o foo -ansi -fno-asm -O2 -Wall -lm --static -DONLINE_JUDGE
Free Pascal(FPC): fpc -Sd -O2 -Op2 -dONLINE_JUDGE
Java: No special options
Our compiler software version:
gcc/g++ 4.7.2 (Debian 4.7.2-5)
GNU C Library (Debian EGLIBC 2.13-38+deb7u6)
Free Pascal Compiler version 2.6.0-9 [2013/04/14] for x86_64
java version "1.7.0_40"
Python 2.7.3
perl 5, version 14, subversion 2 (v5.14.2)
Scheme Guile 1.8.8
PHP 5.4.4-14+deb7u5 (cli)

Q:Free Pascal Runtime Error Numbers
A:Refer to here http://www.freepascal.org/docs-html/user/node16.html for detailed runtime error informations.
We list some frequently used error numbers here:
  • 200 Division by zero
  • 201 Range check error
  • 202 Stack overflow error
  • 203 Heap overflow error
  • 204 Invalid pointer operation
  • 205 floating point overflow
  • 206 floating point underflow
  • 207 invalid floating point operation
  • 216 General Protection fault
    Q:Where is the input and the output?
    A:Your program shall read input from stdin('Standard Input') and write output to stdout('Standard Output').For example,you can use 'scanf' in C or 'cin' in C++ to read from stdin,and use 'printf' in C or 'cout' in C++ to write to stdout.
    User programs are not allowed to open and read from/write to files, you will get a "Runtime Error" if you try to do so.
    Here is a sample solution for problem 1001 using C++:
    #include <iostream>
    using namespace std;
    
    int main()
    {
        int a,b;
        while(cin >> a >> b)
            cout << a+b << endl;
    }
    
    
    Here is a sample solution for problem 1001 using C:
    #include <stdio.h>
    
    int main()
    {
        int a,b;
        while(scanf("%d %d",&a, &b) != EOF)
            printf("%d\n",a+b);
        return 0;
    }
    
    
    Here is a sample solution for problem 1001 using PASCAL(FPC):
    
    program p1001(Input,Output); 
    var 
      a,b:Integer; 
    begin 
       while not eof(Input) do 
         begin 
           Readln(a,b); 
           Writeln(a+b); 
         end; 
    end.
    
    
    Here is a sample solution for problem 1001 using Java:
    
    import java.util.Scanner;
    
    public class Main {
    	public static void main(String[] args) {
    		Scanner in = new Scanner(System.in);
    		while (in.hasNextInt()) {
    			int a = in.nextInt();
    			int b = in.nextInt();
    			System.out.println(a + b);
    		}
    	}
    }
    
    
    Here is a sample solution for problem 1001 using Python:
    
    import sys
    for line in sys.stdin:
        a = line.split()
        print int(a[0]) + int(a[1])
    
    
    Here is a sample solution for problem 1001 using PHP:
    
    <?php
    while (fscanf(STDIN, "%d%d", $a, $b) == 2) {
        print ($a + $b) . "\n";
    }
    
    

    Q:Why did I get a Compile Error? It's well done!
    A:There are some differences between GNU and MS-VC++, such as:
    • main must be declared as int, void main will end up with a Compile Error.
    • i is out of definition after block "for(int i=0...){...}"
    • itoa is not an ANSI function.
    • __int64 of VC is not ANSI, but you can use long long for 64-bit integer.

    Q:What is the meaning of the judge's reply XXXXX?
    A:Here is a list of the judge's replies and their meaning:

    Queuing : The judge is so busy that it can't judge your submit at the moment, usualy you just need to wait a minute and your submit will be judged.

    Accepted : OK! Your program is correct!.

    Presentation Error : Your output format is not exactly the same as the judge's output, although your answer to the problem is correct. Check your output for spaces, blank lines,etc against the problem output specification.

    Wrong Answer : Correct solution not reached for the inputs. The inputs and outputs that we use to test the programs are not public (it is recomendable to get accustomed to a true contest dynamic ;-).

    Time Limit Exceeded : Your program tried to run during too much time.

    Memory Limit Exceeded : Your program tried to use more memory than the judge default settings.

    Output Limit Exceeded: Your program tried to write too much information. This usually occurs if it goes into a infinite loop. Currently the output limit is 1M bytes.

    Non-zero Exit Code: Your program exited returning a non-zero value to the shell. For languages such as C, this probably means you forgot to add "return 0" at the end of the program. For interpreted languages NZEC will usually mean that your program either crashed or raised an uncaught exception.

    Compile Error : The compiler (gcc, g++, fpc, etc) could not compile your program. Of course, warning messages are not error messages. Click the link at the judge reply to see the actual error message.

    Out Of Contest Time: this message can only appear during a contest, if a program is submitted out of contest time.

    No such problem: Either you have submitted a wrong problem id or the problem is unavailable.

    Segmentation Fault : The possible cases of your encountering this error are:

    • 1.buffer overflow --- usually caused by a pointer reference out of range.
    • 2.stack overflow --- please keep in mind that the default stack size is 8192K.

    Floating Point Error : Divide by 0

    Runtime Error : See FAQ below

    Q:How to submit a Java solution?
    A: See the sample solution above. Basically you should submit a single source file which contains a public class Main and it should have a method with signature "public static void main(String[] args)" which is the entry of your program.

    Q:Which Java classes can I use?
    A: You can only use classes in those packages: java.lang, java.io, java.nio, java.math, java.util, java.text and java.net. You are not allowed to catch any Error in your try-catch, read, write or create any file, or create Socket, etc. In one word, don't do anything other than solving the problem.

    Q:What does Runtime Error mean?
    A: If you are using Java, please check the class signature as well as the main method signature, and don't use any class which is not allowed. If you are using other languages, your program may have executed a forbidden operation, like invoking privileged syscalls, file operation, etc. Notice that buffer overflow and stack overflow can also lead to this error.