Skip to content

常见问题

各个评测状态的含义?

下面是评测状态的含义表:

状态含义
等待
Pending
评测机繁忙,暂时无法评测你的提交,通常只需等待一分钟左右,你的提交就会被评测。
运行 & 评测
Running & Judge
你的代码正在运行,并且正在被评测。
编译错误
Compile Error
你的代码无法通过编译,通常是因为你的代码中有语法错误。
通过
Accepted
你的程序是正确的!
格式错误
Presentation Error
你的输出格式与评测的输出格式不完全一致,尽管你的答案可能是正确的。请检查你的输出格式、空格、空行等是否符合题目输出规范。
答案错误
Wrong Answer
你的程序没有得到正确的结果。
运行错误
Runtime Error
你的程序在运行时发生了错误,通常是由于数组越界、除零等原因。
时间超限
Time Limit Exceeded
你的程序运行时间超过了评测允许的时间。
内存超限
Memory Limit Exceeded
你的程序使用的内存超过了评测允许的内存。
输出超限
Output Limit Exceeded
你的程序输出了太多的信息。这通常是由于你的程序进入了一个无限循环。
系统错误
System Error
评测机发生了错误,这可能不是你的问题,请坐和放宽。

评测机的编译 / 运行环境?

评测机的编译器 / 运行时环境如下:

语言编译器 / 运行时编译选项 / 运行选项
Cgcc 12.2.0gcc Main.c -o Main -std=c11 -O2 -lm -DONLINE_JUDGE -w --static
C++ 11g++ 12.2.0g++ Main.cpp -o Main -std=c++11 -O2 -lm -DONLINE_JUDGE -w --static
C++ 17g++ 12.2.0g++ Main.cpp -o Main -std=c++17 -O2 -lm -DONLINE_JUDGE -w --static
Javaopenjdk & javac 17.0.14javac Main.java -encoding UTF-8
java -DONLINE_JUDGE Main
Python 3Python 3.11.2python -m py_compile Main.py
python Main.py
PyPy 3Python 3.9.16
PyPy 7.3.11
pypy3 -m py_compile Main.py
pypy3 Main.py

我的程序能知道它是在评测机上运行吗?

是的,你可以通过不同的方式来判断你的程序是否在评测机上运行。C 和 C++ 通过宏定义,Java 通过系统属性,Python 通过环境变量来得知程序是否在评测机上运行。下面给出了一些示例:

C / C++

c
#include <stdio.h>

int main() {
#ifdef ONLINE_JUDGE
    printf("Running on the judge\n");
#else
    printf("Not running on the judge\n");
#endif
    return 0;
}

Java

java
public class Main {
    public static void main(String[] args) {
        if (System.getProperty("ONLINE_JUDGE") != null) {
            System.out.println("Running on the judge");
        } else {
            System.out.println("Not running on the judge");
        }
    }
}

Python 3 / PyPy 3

python
import os

if os.getenv("ONLINE_JUDGE") == "1":
    print("Running on the judge")
else:
    print("Not running on the judge")

为什么我本地能编译通过的 C / C++ 代码在评测机上编译失败了?

或许是因为 GNU 和 MS-VC++ 之间存在一些差异,例如:

  • main 必须声明为 intvoid main 会导致编译错误。
  • ifor (int i=0; ...) {...} 之后就超出了定义范围。
  • itoa 不是 ANSI 函数。
  • VC 的 __int64 不是 ANSI,但你可以使用 long long 来表示 64 位整数。