Frequently Asked Questions

  1. Where does my program input from and output to?
  2. What are the compilers provided by the judge?
  3. Can I use shortcut keys when submitting?
  4. How is my program judged?
  5. What are the meanings of the judge's replies?
  6. What does the phrase "Special Judge" under the problem title means?
  7. How should I determine the end of input?
  8. My program gets WA/TLE/RE when compiled by GCC/G++ (C/C++), but it's AC when compiled by C/C++ (GCC/G++)!
  9. The time limit is 1000MS. But some people's programs run for several seconds to get AC!
  10. My program exceeds the time limit by just 15MS. How can I improve it?
  11. I have more questions.

Q: Where does my program input from and output to?

A: Your program should always input from stdin (standard input) and output to stdout (standard output). For example, you can use scanf in C or cin in C++ to read, and printf in C or cout in C++ to write. User programs are NOT allowed to open and read from/write to any file. You will probably get responded with Runtime Error or Wrong Answer if you try to do so. 

More should be noted about I/O operations in C++. Due to their complex underlying implementation models, cin and cout are comparatively slower than scanf and printf. The difference in performance is shown by many experiences to be more significant if the program is compiled by G++. Therefore if a problem has huge input, using cin and cout will possibly lead to Time Limit Exceed.

 


Q: What are the compilers provided by the judge?

A: Currently five compilers are provided for six language options. For C and C++, MS-VC++ 6.0 is used. For GCC/G++, MinGW GCC/G++ 3.4.2 is used. For Pascal, FreePascal 2.0.0 is used. For Java, JDK 1.5.0 is used. Below are sample solutions to Problem 1000 in different languages along with some additional notes.

 

C and GCC:

#include <stdio.h>

 

int main(void)

{

    int a, b;

    scanf("%d %d", &a, &b);

    printf("%d\n", a + b);

    return 0;

}

 

C++ and G++:

#include <iostream>

 

using namespace std;

 

int main(void)

{

    int a, b;

    cin >> a >> b;

    cout << a + b << endl;

    return 0;

}

 

Additional notes for GCC/G++:

For 64-bit integers, both long long int and __int64 is supported and they are equivalent. But only "%I64d" is supported when reading with scanf or writing with printf. "%lld" is not supported because GCC and G++ from MinGW use msvcrt.dll which does not support the C99 standard.

(G++ only) As required by the ISO C++ standard, the return type of the main function must be int, otherwise it will cause Compile Error.

 

Pascal:

Program p1000(Input, Output);

Var

    a, b: Integer;

 

Begin

    Readln(a, b);

    Writeln(a + b);

End.

 

Java:

import java.util.*;

 

public class Main

{

    public static void main(String args[])

    {

        Scanner cin = new Scanner(System.in);

        int a = cin.nextInt(), b = cin.nextInt();

        System.out.println(a + b);

    }

}

 

Additional notes for Java:

A Java program must be submitted as a single source file. Apart from complying with restrictions imposed on all submitted programs, it must start execution in a static method named main in a class named Main, otherwise Compile Error will be caused. Except for the aforementioned restrictions, you can implement and  instantiate as many classes as needed.

A program for JDK 1.4 is provided here for reference.

import java.io.*;
import java.util.*;

public class Main
{
    public static void main (String args[]) throws Exception
    {
        BufferedReader stdin =
            new BufferedReader(
                new InputStreamReader(System.in));

        String line = stdin.readLine();
        StringTokenizer st = new StringTokenizer(line);
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        System.out.println(a + b);
    }
}

 


Q: Can I use shortcut keys when submitting?

A: Here are the shortcut keys defined in the submit page:

ALT+s

Submit button

ALT+u

User ID field, if you haven't logged in

ALT+l

Language options

ALT+p

Problem ID field

 


Q: How is my program judged?

A: The judge first saves your submitted program to a file then tries to compile with the compiler corresponding to your selected language option. If compilation fails, Compile Error is returned. The judge then runs your program, feeds the input data to it through the handle to its standard input and does the timing at the same time. Input data are stored in one or more files. Each file is used for judging your program exactly once. During the execution, if the judge finds that your program's running state meet the criteria for Runtime Error, Time Limit Exceed, Memory Limit Exceed or Output Limit Exceed, the result is immediately returned. No further judging will be done. This implies that in the cases of TLE or MLE, it cannot be told whether your program will eventually produce all correct answers given sufficient resources. When your program finishes one input file and produces some output which is saved to an output file, the judge compares the output file against the file containing the corresponding expected output or uses a special judge program to check the output. If the output is incorrect and does not meet the criteria for Presentation Error, Wrong Answer is returned. Otherwise the judge will run your program again to deal with the next input file. After finishing all input files, if your program has avoided the appearance of all six results mentioned above but produced some output that meets the criteria for Presentation Error, this result is returned. Otherwise Accepted is returned.

 


Q: What are the meanings of the judge's replies?

A: Here is a list of the judge's replies with their common abbreviations and exact meanings:

Waiting: Your program is being judged or waiting to be judged.

 

Accepted (AC): Congratulations! Your program has produced the correct output!

 

Presentation Error (PE): Your program's output format is not exactly the same as required by the problem, although the output is correct. This usually means the existence of omitted or extra blank characters (white spaces, tab characters and/or new line characters) between any two non-blank characters, and/or blank lines (a line consisting of only blank characters) between any two non-blank lines. Trailing blank characters at the end of each line and trailing blank lines at the of output are not considered format errors. Check the output for spaces, blank lines, etc. against the problem's output specification.

 

Wrong Answer (WA): Your program does not produce the correct output. Special judge programs will possibly return Wrong Answer in place of Presentation Error for simplicity and robustness.

 

Runtime Error (RE): Your program has failed during the execution. Possible causes include illegal file access, stack overflow, out of range in pointer reference, floating point exception, division by zero and many others. Programs that stay not responding for a long time (not consuming CPU cycles) may also be considered to have encountered runtime errors.

 

Time Limit Exceed (TLE): The total time your program has run for has exceeded the limit.

Each problem has two time limits - TOTAL TIME LIMIT and CASE TIME LIMIT. The former is the total time allowed for your program to deal with all input files. And the latter is the total time allowed for your program to deal with a single input file. Exceeding either one will lead to Time Limit Exceed. If you get Time Limit Exceed but find that your program has run for less time than is limited, your program must have exceeded that CASE TIME LIMIT.

Problems without a special demand on the time limit for a single input file will have its case time limit is trivially set as the same as its total time limit and the phrase "Case Time Limit" will not show up under the problem title.

Memory Limit Exceed (MLE): The maximum amount of memory that your program has used has exceeded the limit.

 

Output Limit Exceed (OLE): Your program has produced too much output. Currently the limit is twice the size of the file containing the expected output. The most common cause of this result is that your programs falls into an infinite loop containing some output operations.

 

Compile Error (CE): The compiler fails to compile your program. Warning messages are not considered errors. Click on the judge's reply to see the warning and error messages produced by the compiler.

 

No such problem: Either you have submitted with a non-existent problem id or the problem is currently unavailable (probably reserved for upcoming contests).

 

System Error: The judge cannot run your program. One example is that your program requires much more memory than hardware limitation.

 

Validate Error: The special judge program fails in checking your output, which means it may contain some bugs. If you get this result, please contact the administrator. (Of course, this also means your output is probably wrong).

 


Q: What does the phrase "Special Judge" under the problem title means?

A: When a problem has multiple acceptable answers, a special judge program is needed. The special judge program uses the input data and some other information to check your program's output and returns the result to the judge.

 


Q: How should I determine the end of input?

A: In most cases there is some information in the input that explicitly indicates the end of input, for example, number of test cases or a single line with one or more zeroes following that last test case. But in some cases you have to determine the end of file (EOF) for the end of input. In such cases, you can test the return value of scanf (which returns how many values have been successfully read in or EOF if none has been read) or !cin. Refer to the hints for Problem 1001 for a working example.

 


Q: My program gets WA/TLE/RE when compiled by GCC/G++ (C/C++), but it's AC when compiled by C/C++ (GCC/G++)!

A: It's probably caused by some minor bugs hiding in your AC code which have not lead to visible effects due to compiler factors. It is recommended that you revise your code to fix the bugs in this case. Another possible cause is the fact that different compilers generally use different methods, libraries and settings to generate executable files. Therefore it is possible for the executable files generated by different compilers to have different efficiency or even different behaviors in some special cases. For example, the stack size of programs compiled by MS-VC++ is larger than that of those compiled by GCC/G++. A program relying on extremely deep recursion may possibly fail if compiled by GCC/G++. If you strongly believe (with sufficient evidence) what you have encountered is caused by bugs of the compilers, please let us know.

 


Q: The time limit is 1000MS. But some people's programs run for several seconds to get AC!

A: Most such programs are Java programs. As is known to all, Java programs run much slower than C/C++ programs. Therefore the time limits for Java programs are longer. Concretely speaking, Java programs are allowed to run for THREE TIMES the time limit and are given another 150MS for each input file out of consideration for I/O efficiency. If the program your find does not belong to any case mentioned above, please let us know.

 


Q: My program exceeds the time limit by just 15MS. How can I improve it?

A: In most cases your program actually requires much more time than the time limit. The judge kills the process instantiating your program once the time limit is exceeded. Usually this occurs 15MS after the limit is exceeded. Common skills in code improvement include reducing constant factor and using efficient algorithms.

 


Q: I have more questions.

A: Please make full use of our web board. Post your questions in a nice way. The administrators and other users will try to help you.

Home Page   Go Back  To top


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