Yu-Judge-Core 用户文档
输入“/”快速插入内容
Yu-Judge-Core 用户文档
总述
这是 Online Judge 平台
YuJudge
的
判题核心
,基于
C
编写,支持在 Linux 下运行。
本程序基于用户的可执行文件以及标准输入输出目录、资源限制等配置,执行并给出资源消耗情况,并能防止恶意调用。
关于操作系统版本问题 本程序在 CentOS 7 下完成开发与测试,故强烈建议在 CentOS 7 下运行本程序
,其它的版本理论上可以运行,但不保证不出现问题。
快速开始
clone 项目
代码块
Bash
git clone https://github.com/yuzhanglong/YuJudge-Core.git
安装必要的依赖
代码块
Bash
# 进入项目根目录
cd YuJudge-Core
编译项目
项目提供了一键编译脚本,直接执行根目录下的
build.sh
即可:
代码块
Bash
# 保证可执行权限
chmod 777 ./build.sh
# 安装必要的依赖
yum -y install java-1.8.0-openjdk.x86_64 java-1.8.0-openjdk-devel python3 gcc gcc-c++ libseccomp-devel git cmake make zip unzip
# 执行构建脚本
./build.sh
编译、执行可执行文件
本代码
仓库
自带了一个 C 语言程序
DEMO
(位于
/examples/quick-start
目录下)下面简称
DEMO 程序
,下面我们以该代码为例尝试运行判题核心,其内容如下,它接受用户输入一个整数,然后输出
“hello world”
字符串:
代码块
C
/*
* C 语言的 hello world 项目
* 程序接受用户输入一个整数,
* 程序只有一行输出,为 'hello world' 字符串
*/
#include<stdio.h>
int main(void) {
int a;
scanf("%d", &a);
printf("hello world!\n");
return 0;
}
首先,执行下面的命令编译
DEMO
程序,他会在 DEMO 程序所在目录下生成
run-hello-world.out
可执行文件:
代码块
Bash
gcc -Wall -O2 -std=gnu11 examples/quick-start/hello-world.c -o examples/quick-start/run-hello-world.out -lm
最后,执行下面的命令,调用判题核心执行该可执行文件:
代码块
Bash
# -r 指定可执行文件路径,-i 指定标准输入路径,-o 指定标准输出路径
build/y_judge -r ./examples/quick-start/run-hello-world.out \
-i ./examples/quick-start/hello-world.in \
-o ./test.out