2019-03-13 09:57:59 +00:00
|
|
|
from problem.models import ProblemIOMode
|
|
|
|
|
|
|
|
|
2018-03-23 11:39:46 +00:00
|
|
|
default_env = ["LANG=en_US.UTF-8", "LANGUAGE=en_US:en", "LC_ALL=en_US.UTF-8"]
|
2017-01-24 05:22:40 +00:00
|
|
|
|
|
|
|
_c_lang_config = {
|
2017-11-26 05:30:07 +00:00
|
|
|
"template": """//PREPEND BEGIN
|
2017-02-06 08:41:14 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
//PREPEND END
|
|
|
|
|
|
|
|
//TEMPLATE BEGIN
|
|
|
|
int add(int a, int b) {
|
|
|
|
// Please fill this blank
|
|
|
|
return ___________;
|
|
|
|
}
|
|
|
|
//TEMPLATE END
|
|
|
|
|
2017-11-26 05:30:07 +00:00
|
|
|
//APPEND BEGIN
|
2017-02-06 08:41:14 +00:00
|
|
|
int main() {
|
|
|
|
printf("%d", add(1, 2));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//APPEND END""",
|
2017-01-24 05:22:40 +00:00
|
|
|
"compile": {
|
|
|
|
"src_name": "main.c",
|
|
|
|
"exe_name": "main",
|
|
|
|
"max_cpu_time": 3000,
|
2018-05-16 17:28:08 +00:00
|
|
|
"max_real_time": 10000,
|
2017-11-02 13:37:47 +00:00
|
|
|
"max_memory": 256 * 1024 * 1024,
|
2018-03-18 02:29:34 +00:00
|
|
|
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c11 {src_path} -lm -o {exe_path}",
|
2017-01-24 05:22:40 +00:00
|
|
|
},
|
|
|
|
"run": {
|
|
|
|
"command": "{exe_path}",
|
2019-03-13 09:57:59 +00:00
|
|
|
"seccomp_rule": {ProblemIOMode.standard: "c_cpp", ProblemIOMode.file: "c_cpp_file_io"},
|
2018-03-23 11:39:46 +00:00
|
|
|
"env": default_env
|
2017-01-24 05:22:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_c_lang_spj_compile = {
|
|
|
|
"src_name": "spj-{spj_version}.c",
|
|
|
|
"exe_name": "spj-{spj_version}",
|
|
|
|
"max_cpu_time": 3000,
|
2018-05-16 17:28:08 +00:00
|
|
|
"max_real_time": 10000,
|
2017-01-24 05:22:40 +00:00
|
|
|
"max_memory": 1024 * 1024 * 1024,
|
2018-03-18 02:29:34 +00:00
|
|
|
"compile_command": "/usr/bin/gcc -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c11 {src_path} -lm -o {exe_path}"
|
2017-01-24 05:22:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_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 = {
|
2017-11-26 05:30:07 +00:00
|
|
|
"template": """//PREPEND BEGIN
|
|
|
|
#include <iostream>
|
|
|
|
//PREPEND END
|
|
|
|
|
|
|
|
//TEMPLATE BEGIN
|
|
|
|
int add(int a, int b) {
|
|
|
|
// Please fill this blank
|
|
|
|
return ___________;
|
|
|
|
}
|
|
|
|
//TEMPLATE END
|
|
|
|
|
|
|
|
//APPEND BEGIN
|
|
|
|
int main() {
|
|
|
|
std::cout << add(1, 2);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
//APPEND END""",
|
2017-01-24 05:22:40 +00:00
|
|
|
"compile": {
|
|
|
|
"src_name": "main.cpp",
|
|
|
|
"exe_name": "main",
|
|
|
|
"max_cpu_time": 3000,
|
2018-05-16 17:28:08 +00:00
|
|
|
"max_real_time": 10000,
|
2017-11-06 11:05:21 +00:00
|
|
|
"max_memory": 512 * 1024 * 1024,
|
2018-03-18 02:29:34 +00:00
|
|
|
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++14 {src_path} -lm -o {exe_path}",
|
2017-01-24 05:22:40 +00:00
|
|
|
},
|
|
|
|
"run": {
|
|
|
|
"command": "{exe_path}",
|
2019-03-28 02:48:55 +00:00
|
|
|
"seccomp_rule": {ProblemIOMode.standard: "c_cpp", ProblemIOMode.file: "c_cpp_file_io"},
|
2018-03-23 11:39:46 +00:00
|
|
|
"env": default_env
|
2017-01-24 05:22:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-26 09:14:40 +00:00
|
|
|
_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,
|
2018-03-18 02:29:34 +00:00
|
|
|
"compile_command": "/usr/bin/g++ -DONLINE_JUDGE -O2 -w -fmax-errors=3 -std=c++14 {src_path} -lm -o {exe_path}"
|
2017-01-26 09:14:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_cpp_lang_spj_config = {
|
|
|
|
"exe_name": "spj-{spj_version}",
|
|
|
|
"command": "{exe_path} {in_file_path} {user_out_file_path}",
|
|
|
|
"seccomp_rule": "c_cpp"
|
|
|
|
}
|
|
|
|
|
2017-01-24 05:22:40 +00:00
|
|
|
_java_lang_config = {
|
2017-12-01 13:53:13 +00:00
|
|
|
"template": """//PREPEND BEGIN
|
|
|
|
//PREPEND END
|
|
|
|
|
|
|
|
//TEMPLATE BEGIN
|
|
|
|
//TEMPLATE END
|
|
|
|
|
|
|
|
//APPEND BEGIN
|
|
|
|
//APPEND END""",
|
2017-01-24 05:22:40 +00:00
|
|
|
"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": {
|
2018-03-23 11:39:46 +00:00
|
|
|
"command": "/usr/bin/java -cp {exe_dir} -XX:MaxRAM={max_memory}k -Djava.security.manager -Dfile.encoding=UTF-8 "
|
|
|
|
"-Djava.security.policy==/etc/java_policy -Djava.awt.headless=true Main",
|
2017-01-24 05:22:40 +00:00
|
|
|
"seccomp_rule": None,
|
2018-03-23 11:39:46 +00:00
|
|
|
"env": default_env,
|
|
|
|
"memory_limit_check_only": 1
|
2017-01-24 05:22:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_py2_lang_config = {
|
2017-12-01 13:53:13 +00:00
|
|
|
"template": """//PREPEND BEGIN
|
|
|
|
//PREPEND END
|
|
|
|
|
|
|
|
//TEMPLATE BEGIN
|
|
|
|
//TEMPLATE END
|
|
|
|
|
|
|
|
//APPEND BEGIN
|
|
|
|
//APPEND END""",
|
2017-01-24 05:22:40 +00:00
|
|
|
"compile": {
|
|
|
|
"src_name": "solution.py",
|
|
|
|
"exe_name": "solution.pyc",
|
|
|
|
"max_cpu_time": 3000,
|
2018-05-16 17:28:08 +00:00
|
|
|
"max_real_time": 10000,
|
2017-01-24 05:22:40 +00:00
|
|
|
"max_memory": 128 * 1024 * 1024,
|
|
|
|
"compile_command": "/usr/bin/python -m py_compile {src_path}",
|
|
|
|
},
|
|
|
|
"run": {
|
|
|
|
"command": "/usr/bin/python {exe_path}",
|
2017-02-02 08:59:15 +00:00
|
|
|
"seccomp_rule": "general",
|
2018-03-23 11:39:46 +00:00
|
|
|
"env": default_env
|
2017-01-24 05:22:40 +00:00
|
|
|
}
|
|
|
|
}
|
2017-11-29 13:44:05 +00:00
|
|
|
_py3_lang_config = {
|
2017-12-01 13:53:13 +00:00
|
|
|
"template": """//PREPEND BEGIN
|
|
|
|
//PREPEND END
|
|
|
|
|
|
|
|
//TEMPLATE BEGIN
|
|
|
|
//TEMPLATE END
|
|
|
|
|
|
|
|
//APPEND BEGIN
|
|
|
|
//APPEND END""",
|
2017-11-29 13:44:05 +00:00
|
|
|
"compile": {
|
|
|
|
"src_name": "solution.py",
|
|
|
|
"exe_name": "__pycache__/solution.cpython-35.pyc",
|
|
|
|
"max_cpu_time": 3000,
|
2018-05-16 17:28:08 +00:00
|
|
|
"max_real_time": 10000,
|
2017-11-29 13:44:05 +00:00
|
|
|
"max_memory": 128 * 1024 * 1024,
|
|
|
|
"compile_command": "/usr/bin/python3 -m py_compile {src_path}",
|
|
|
|
},
|
|
|
|
"run": {
|
|
|
|
"command": "/usr/bin/python3 {exe_path}",
|
|
|
|
"seccomp_rule": "general",
|
2018-03-23 11:39:46 +00:00
|
|
|
"env": default_env
|
2017-11-29 13:44:05 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-24 05:22:40 +00:00
|
|
|
|
|
|
|
languages = [
|
|
|
|
{"config": _c_lang_config, "spj": {"compile": _c_lang_spj_compile, "config": _c_lang_spj_config},
|
2018-03-18 02:29:34 +00:00
|
|
|
"name": "C", "description": "GCC 5.4", "content_type": "text/x-csrc"},
|
2017-01-26 09:14:40 +00:00
|
|
|
{"config": _cpp_lang_config, "spj": {"compile": _cpp_lang_spj_compile, "config": _cpp_lang_spj_config},
|
2018-03-18 02:29:34 +00:00
|
|
|
"name": "C++", "description": "G++ 5.4", "content_type": "text/x-c++src"},
|
2018-03-23 11:39:46 +00:00
|
|
|
{"config": _java_lang_config, "name": "Java", "description": "OpenJDK 1.8", "content_type": "text/x-java"},
|
2017-11-29 13:44:05 +00:00
|
|
|
{"config": _py2_lang_config, "name": "Python2", "description": "Python 2.7", "content_type": "text/x-python"},
|
2018-03-18 02:29:34 +00:00
|
|
|
{"config": _py3_lang_config, "name": "Python3", "description": "Python 3.5", "content_type": "text/x-python"},
|
2017-01-24 05:22:40 +00:00
|
|
|
]
|