Onlinejudge Coding Guidelines

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.

Frequently Asked Questions Answered

  1. What is Online Judge?
  2. What are the possible judge results?
  3. What programming language does NOJ support?
  4. What is the system compile command?
  5. What is the basic code structure?
  6. How to use 64-bit integer data types?
  7. I forgot my password?
  8. How to set my avatar?
  9. Online Judge server configuration?
  10. How to post code in discussion forum?
  11. I have more question?

What is Online Judge?

An online judge is an online system to test programs in programming contests. They are also used to practice for such contests. Many of these systems organize their own contests.

The system can compile and execute code, and test them with pre-constructed data. Submitted code may be run with restrictions, including time limit, memory limit, security restriction and so on. The output of the code will be captured by the system, and compared with the standard output. The system will then return the result. When mistakes were found in a standard output, rejudgement using the same method must be made. Online Judges have ranklists showing users with the biggest number of accepted solutions and shortest execution time for a particular problem.

What is the judge result?

Accepted(AC) - your program ran successfully and gave a correct answer. if you truly think your code is correct, you can contact us. Judge's ouputs are not always correct...

Wrong Answer(WA) - your program ran successfully, but gave an incorrect answer

Time Limit Exceeded(TLE) - your program was compiled successfully, but it didn't stop before time limit

Memory Limit Exceeded(MLE) - your program was compiled successfully, but it didn't solve the problem before memory limit

Compilation Error(CE) - your program couldn't be compiled; compiler's errors can be seen from www and are sent via mail if your preferences say so; note: only some languages can give CE, syntax errors in intrerpreted languages can lead to WA (Python - no pre-checking syntax or Perl - CE only afer a basic syntax check)

Runtime Error(RE) - Your program failed during the execution (segmentation fault, floating point exception...). the exact cause is not reported to the user to avoid hacking.

Restricted Function(RF) - your program contains unnecessary system call. For security purposes the online judge system will block those system call. e.g..: fopen, fork, fread...

Output Limit Exceed(OLE) - your program tried to write too much information. This usually occurs if it goes into a infinite loop.

What programming language does NOJ support?

NUC Online Judge support C and C++ programming language. ACM/ICPC support only C, C++ and Java. So, we will add Java as well in the future.

What is NOJ compile command line?

OJ system use following cmd line to compile:
gcc -O2 -std=gnu99 -fno-asm -lm -Wall -w -static -DONLINE_JUDGE
g++ -O2 -std=gnu++0x -fno-asm -lm -Wall -w -static -DONLINE_JUDGE
pre-include header files:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
#include <inttypes.h>

What is the basic code structure?

C code structure:
#include <stdio.h>
int main() //do not use void main()
    return 0;
C++ code structure:
#include <iostream> //do not use #include <iostream.h>
using namespace std;
int main()
    return 0;

How to use 64-bit integer data types?

The compiler fully supports 64-bit integers (both signed and unsigned). A signed 64-bit integer ranges from –9223372036854775808 to 9223372036854775807 and an unsigned 64-bit integer ranges from 0 to 18446744073709551615. A 64-bit variable can be declared in the following way:

long long a;
unsigned long long b;

64-bit variables can be read and written in two ways as well depending on the input/output library used:

#include <stdio.h>
scanf("%lld", &a);
scanf("%llu", &b);
printf("%lld", a);
printf("%llu", b);

#include <iostream>
std::cin >> a;
std::cin >> b;
std::cout << a;
std::cout << b;

I forgot my password?

Click here to reset your password! If this doesn't work properly for you, please email us.

Online Judge server configuration?

Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz(8 cores) x 2
RAM 2.00 GB
Debian GNU/Linux
gcc version 4.7.2
glibc version 2.13
ojcore 1.1

North University of China