mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-29 08:32:08 +00:00
53d0cae8ea
add ordering for contest and submission models
145 lines
4.1 KiB
Python
145 lines
4.1 KiB
Python
|
|
|
|
_c_lang_config = {
|
|
"template": """//PREPEND START
|
|
#include <stdio.h>
|
|
//PREPEND END
|
|
|
|
//TEMPLATE BEGIN
|
|
int add(int a, int b) {
|
|
// Please fill this blank
|
|
return ___________;
|
|
}
|
|
//TEMPLATE END
|
|
|
|
//APPEND START
|
|
int main() {
|
|
printf("%d", add(1, 2));
|
|
return 0;
|
|
}
|
|
//APPEND END""",
|
|
"compile": {
|
|
"src_name": "main.c",
|
|
"exe_name": "main",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": 128 * 1024 * 1024,
|
|
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}",
|
|
},
|
|
"run": {
|
|
"command": "{exe_path}",
|
|
"seccomp_rule": "c_cpp",
|
|
}
|
|
}
|
|
|
|
_c_lang_spj_compile = {
|
|
"src_name": "spj-{spj_version}.c",
|
|
"exe_name": "spj-{spj_version}",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": 1024 * 1024 * 1024,
|
|
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c99 {src_path} -lm -o {exe_path}"
|
|
}
|
|
|
|
_c_lang_spj_config = {
|
|
"exe_name": "spj-{spj_version}",
|
|
"command": "{exe_path} {in_file_path} {user_out_file_path}",
|
|
"seccomp_rule": "c_cpp"
|
|
}
|
|
|
|
_cpp_lang_config = {
|
|
"template": """/*--PREPEND START--*/
|
|
/*--PREPEND END--*/
|
|
/*--TEMPLATE BEGIN--*/
|
|
/*--TEMPLATE END--*/
|
|
/*--APPEND START--*/
|
|
/*--APPEND END--*/""",
|
|
"compile": {
|
|
"src_name": "main.cpp",
|
|
"exe_name": "main",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": 128 * 1024 * 1024,
|
|
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++11 {src_path} -lm -o {exe_path}",
|
|
},
|
|
"run": {
|
|
"command": "{exe_path}",
|
|
"seccomp_rule": "c_cpp"
|
|
}
|
|
}
|
|
|
|
_cpp_lang_spj_compile = {
|
|
"src_name": "spj-{spj_version}.cpp",
|
|
"exe_name": "spj-{spj_version}",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": 1024 * 1024 * 1024,
|
|
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++11 {src_path} -lm -o {exe_path}"
|
|
}
|
|
|
|
_cpp_lang_spj_config = {
|
|
"exe_name": "spj-{spj_version}",
|
|
"command": "{exe_path} {in_file_path} {user_out_file_path}",
|
|
"seccomp_rule": "c_cpp"
|
|
}
|
|
|
|
_java_lang_config = {
|
|
"template": """/*--PREPEND START--*/
|
|
/*--PREPEND END--*/
|
|
/*--TEMPLATE BEGIN--*/
|
|
/*--TEMPLATE END--*/
|
|
/*--APPEND START--*/
|
|
/*--APPEND END--*/""",
|
|
"compile": {
|
|
"src_name": "Main.java",
|
|
"exe_name": "Main",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": -1,
|
|
"compile_command": "/usr/bin/javac {src_path} -d {exe_dir} -encoding UTF8"
|
|
},
|
|
"run": {
|
|
"command": "/usr/bin/java -cp {exe_dir} -Xss1M -Xms16M -Xmx{max_memory}k "
|
|
"-Djava.security.manager -Djava.security.policy==/etc/java_policy -Djava.awt.headless=true Main",
|
|
"seccomp_rule": None,
|
|
"env": ["MALLOC_ARENA_MAX=1"]
|
|
}
|
|
}
|
|
|
|
|
|
_py2_lang_config = {
|
|
"template": """/*--PREPEND START--*/
|
|
/*--PREPEND END--*/
|
|
/*--TEMPLATE BEGIN--*/
|
|
/*--TEMPLATE END--*/
|
|
/*--APPEND START--*/
|
|
/*--APPEND END--*/""",
|
|
"compile": {
|
|
"src_name": "solution.py",
|
|
"exe_name": "solution.pyc",
|
|
"max_cpu_time": 3000,
|
|
"max_real_time": 5000,
|
|
"max_memory": 128 * 1024 * 1024,
|
|
"compile_command": "/usr/bin/python -m py_compile {src_path}",
|
|
},
|
|
"run": {
|
|
"command": "/usr/bin/python {exe_path}",
|
|
"seccomp_rule": "general",
|
|
}
|
|
}
|
|
|
|
languages = [
|
|
{"config": _c_lang_config, "spj": {"compile": _c_lang_spj_compile, "config": _c_lang_spj_config},
|
|
"name": "C", "description": "GCC 4.8", "content_type": "text/x-csrc"},
|
|
{"config": _cpp_lang_config, "spj": {"compile": _cpp_lang_spj_compile, "config": _cpp_lang_spj_config},
|
|
"name": "C++", "description": "G++ 4.8", "content_type": "text/x-c++src"},
|
|
{"config": _java_lang_config, "name": "Java", "description": "OpenJDK 1.7", "content_type": "text/x-java"},
|
|
{"config": _py2_lang_config, "name": "Python2", "description": "Python 2.7", "content_type": "text/x-python"}
|
|
]
|
|
|
|
spj_languages = list(filter(lambda item: "spj" in item, languages))
|
|
|
|
|
|
language_names = [item["name"] for item in languages]
|
|
spj_language_names = [item["name"] for item in spj_languages]
|