Tianjin University Online Judge
Contests Virtual Contests Problems Submit Runs Status Rank List Forum

Tianjin University Online Judge FAQ

Q: How can I start?
Q: Where is the input and the output?
Q: What is flag 'X'/'M'/'S' meaning?
Q: Why did I get a Compilation Error? It's well done!
Q: What should I notice with Java?
Q: Is there any way to determine if my program is running at Online Judge or not?
Q: What is the compiler the judge is using and what are the compiler options?
Q: Is there any special format needed for multiple files' problems?
Q: What is the meaning of the judge's reply XXXXX?
Q: What does SIGSEGV in Runtime Error stand for?
Q: What are the parameters for status.php?
Q: Can I use shortcut key when submitting?
Q: What is the meaning of "Rate" in the ranklist?
Q: How to attend Online Contests?
Q: How to add my own problem in the problemset?

Q: How can I start?
A: First you need to register a user, and then you may try to read some problems and submit your solution in C/C++/Pascal/Java. The system will judge your solution, and tell you it is right or wrong.

Note that pass sample input/output does not mean your code is right, the system will test your code with some strict data, so make sure your code fits into the problem description. Your codes must read from Standard Input, and write to Standard Output. Do not try to open a file which is forbidden on Online Judge.

Your codes will be judged automatically, not manually, so no extra output (like "Please input data") needed. The input and output of your codes will be split, you may read and write alternately.

We recommend problem 1001 and problem 2001 for freshman.

A hint for finding easy problems: click the top-right "Ratio" or "AC" in the problem list page, and the problems will be resorted.

Make sure your browser supports JavaScript.


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 "Restricted Function" if you try to do so.

Here is a sample solution for problem 1001 using C:
#include <stdio.h>

int main(void)
{
    int a;
    while(scanf("%d", &a) != EOF)
        putchar(a);
    return 0;
}
Here is a sample solution for problem 1001 using C++:
#include <iostream>
using namespace std;

int main(void)
{
    int a;
    while(cin >> a)
        cout << (char)a;
    return 0;
}
Here is a sample solution for problem 1001 using Pascal (GNU Pascal or Free Pascal):
program p1001;
var
  a:integer;
begin
  while not eof do begin
    while not eoln do begin
      read(a);
      write(chr(a));
    end;
    readln;
  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 cin=new Scanner(System.in);
        int a;
        while(cin.hasNextInt()) {
            a = cin.nextInt();
            System.out.print((char)a);
        }
    }
}

Q: What is flag 'X'/'M'/'S' meaning?
A:
'X' means the problem is not ready, you cannot submit the problem now, generally we need data or special judge program.
'M' means the problem has multiple test files, your program will be executed twice or more with different input data.
'S' means there are not one but several correct answers for the problem, the output of your program will be tested by a special judge program.
Q: Why did I get a Compilation Error? It's well done!
A: Click the link at the judge reply to see the actual error message.
There are some differences between GNU GCC and MS-VC++, such as:
Here is an example for "long long":
#include <stdio.h>
int main(void)
{
	long long a = 1LL << 48;
	printf("%lld\n", a);
	return 0;
}

Q: What should I notice with Java?
A: 1. Please notice the version of our Java compiler, we use JDK 1.5.0.
2. Java programs submitted must be in a single source code (not .class) file.
3. The class which "main" method in must be "Main", otherwise you will get a Compilation Error.
4. The programs must read from standard input and write to standard output, as in the other languages.
5. You will get "Runtime Error" when your program throws an exception to system, detail information is not supported yet.
6. Any of illegal or dangerous operations are forbidden, such as file-open, socket, thread ...
7. Since Java program runs slow, The time limit of each problem will be about twice of the original, and the memory limit is enlarged to 1024M. Notice it may not enough for some problems.

Q: Is there any way to determine if my program is running at Online Judge or not?
A: There is a conditional define of compiler called ONLINE_JUDGE.
Example of using it:

#ifdef ONLINE_JUDGE
//running on oj
#else
//anything you like
#endif

{$IFDEF ONLINE_JUDGE}
{running on oj}
{$ELSE}
{anything you like}
{$ENDIF}   

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++ compile, FPC/GPC for pascal compile and Sun JDK for java compile. The compilation options are:
C: gcc foo.c -o foo -O -march=pentium4m -ansi -fno-asm -Wall -lm -static -DONLINE_JUDGE
C++: g++ foo.cpp -o foo -O -march=pentium4m -ansi -fno-asm -Wall -lm -static -DONLINE_JUDGE
Free Pascal: ppc386 foo.pas -ofoo -Co -Cr -Ct -Ci -dONLINE_JUDGE
GNU Pascal: gpc foo.pas -o foo -O -march=pentiumpro -fno-asm -Wall -lm -static -DONLINE_JUDGE
Java: javac -g:none -Xlint Main.java
Java Run command: java -client Main

Our compiler software version:
gcc/g++ version 4.1.1
glibc version 2.3.6
gpc version 2.1 (20020510), based on gcc-2.95.2 19991024 (release)
Free Pascal Compiler version 2.0.1 [2005/11/28] for i386
java version "1.5.0_09"

Q: Is there any special format needed for multiple files' problems?
A: No, it is nothing different with single one, you can ignore it.

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

Received : The judge system has received your solution, usually you just need to wait a minute and your solution will be judged.

Accepted (AC) : OK! Your program is correct!

Presentation Error (PE) : Output Format 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 (WA) : Correct solution not reached for the inputs. The inputs and outputs that we use to test the programs are not public. Some problems with special judge may not reply "Presentation Error", replaced by "Wrong Answer".

Runtime Error (RE) : Your program failed during the execution (segmentation fault, floating point exception...). The exact cause is reported except Java.

Time Limit Exceeded (TLE) : Your program tried to run with too much CPU time.

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

Output Limit Exceeded (OLE): Your program tried to write too much. This usually occurs if it goes into an infinite loop. The output limit is usually 256K, 512K, or 1M bytes.

Compilation Error (CE) : The compiler (gcc/g++/gpc/fpc/javac) 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.

Restricted Function (RF): Your program tried to call restricted functions. For example, maybe you have tried to open a file which is forbidden on OJ. It may also caused by Runtime Error (e.g. maybe a pointer point to wrong funtion), just consider it as Runtime Error in this situation.

Internal Error (IE): The Judge system cause an internal error, please submit it later.


Q: What does SIGSEGV in Runtime Error stand for?
A: The following messages will not be shown to you in contest. Here we just provide some tips:
SIGSEGV --- Invalid memory reference (segment 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.
  3. illegal file access --- file operations are forbidden on our judge system.
SIGFPE --- Floating point exception (divided by 0)
SIGBUS --- Bus error (bad memory access)
SIGILL --- Illegal Instruction.
SIGABRT --- Programme aborted before it should be finished.
man 7 signal under Linux for more information

Free Pascal Runtime Error Numbers
Refer to here for detailed runtime error informations.
We list some frequently used error numbers here:


Q: What are the parameters for status.php?
A: Here is a list of the parameters for status.php:
pid: List status only for this problem.
user: List status only for this user.
accept: Whatever its value is, this parameter prevent non-Accepted status from being shown.
start: List status whose RunID is no more than it.
end: List status whose RunID is no less than it.
For example, you want to see xxx's all "Accpeted"s whose RunID ≤ 1000, use the following URL:
http://acm.tju.edu.cn/toj/status.php?start=1000&accept=1&user=xxx

Q: Can I use shortcut key when submitting?
A: Here are shortcut keys defined in the submit page.
Alt + u : User ID field
Alt + w : Password field
Alt + p : Problem ID field
Alt + l  : Language field
Alt + c : Source Code field
Alt + r : Source File field
Alt + s or Ctrl + Enter or Ctrl + w : Submit Button

Q: What is the meaning of "Rate" in the ranklist?
A: It is calculated by the following method:
Sp: The total number of authors of problem p, an author means an ID who have solved the problem.
N: The number of problems in the problem set, except problem 1001.





Q: How to attend Online Contests?
A: Can you submit programs for any practice problems on OJ? If you can, then that is the account you use in an online contest. If you can't, then please register an id with password first.

Q: How to add my own problem in the problemset?
A: If you want to add your own problems, you are expected to provide problem text(HTML), Input/Output data(Formatted in Unix), a sample program (C/C++/Pascal), and related information (Time Limit, Memory Limit, Need Special Judge or not, Put in a Contest or not ...)
Please contact us via tjuoj@yahoo.com.cn.

Any questions/suggestions please post to Online Judge Forum


Tianjin University Online Judge v1.3.0
Maintance:G.D.Retop. Developer: SuperHacker, G.D.Retop