pyLynx 2.0.1b3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- Lynx/__init__.py +49 -0
- Lynx/modules/__init__.py +1 -0
- Lynx/modules/compare.py +32 -0
- Lynx/modules/generate.py +42 -0
- Lynx/modules/init.py +80 -0
- Lynx/templates/cpp/additional_file/.gitkeep +0 -0
- Lynx/templates/cpp/problem.yaml +0 -0
- Lynx/templates/cpp/problem_zh.md +3 -0
- Lynx/templates/cpp/programs/checker.cpp +14 -0
- Lynx/templates/cpp/programs/std.cpp +1 -0
- Lynx/templates/cpp/programs/validator.cpp +17 -0
- Lynx/templates/cpp/testdata/config.yaml +95 -0
- Lynx/templates/generator.py +9 -0
- Lynx/utils/__init__.py +1 -0
- Lynx/utils/config.py +20 -0
- Lynx/utils/constants.py +52 -0
- Lynx/utils/language/__init__.py +1 -0
- Lynx/utils/language/cpp.py +51 -0
- Lynx/utils/log.py +17 -0
- pyLynx-2.0.1b3.dist-info/LICENSE +232 -0
- pyLynx-2.0.1b3.dist-info/METADATA +48 -0
- pyLynx-2.0.1b3.dist-info/RECORD +62 -0
- pyLynx-2.0.1b3.dist-info/WHEEL +5 -0
- pyLynx-2.0.1b3.dist-info/entry_points.txt +2 -0
- pyLynx-2.0.1b3.dist-info/top_level.txt +2 -0
- testlib/.git +1 -0
- testlib/.gitattributes +1 -0
- testlib/.gitignore +7 -0
- testlib/LICENSE +21 -0
- testlib/README.md +107 -0
- testlib/checkers/.gitignore +19 -0
- testlib/checkers/acmp.cpp +17 -0
- testlib/checkers/caseicmp.cpp +64 -0
- testlib/checkers/casencmp.cpp +87 -0
- testlib/checkers/casewcmp.cpp +80 -0
- testlib/checkers/dcmp.cpp +16 -0
- testlib/checkers/fcmp.cpp +33 -0
- testlib/checkers/hcmp.cpp +32 -0
- testlib/checkers/icmp.cpp +14 -0
- testlib/checkers/lcmp.cpp +52 -0
- testlib/checkers/ncmp.cpp +53 -0
- testlib/checkers/nyesno.cpp +65 -0
- testlib/checkers/pointscmp.cpp +13 -0
- testlib/checkers/pointsinfo.cpp +14 -0
- testlib/checkers/rcmp.cpp +17 -0
- testlib/checkers/rcmp4.cpp +28 -0
- testlib/checkers/rcmp6.cpp +28 -0
- testlib/checkers/rcmp9.cpp +28 -0
- testlib/checkers/rncmp.cpp +22 -0
- testlib/checkers/uncmp.cpp +51 -0
- testlib/checkers/wcmp.cpp +34 -0
- testlib/checkers/yesno.cpp +26 -0
- testlib/read.me +19 -0
- testlib/testlib.h +6299 -0
- testlib/validators/bipartite-graph-validator.cpp +31 -0
- testlib/validators/case-nval.cpp +27 -0
- testlib/validators/ival.cpp +16 -0
- testlib/validators/nval.cpp +21 -0
- testlib/validators/sval.cpp +17 -0
- testlib/validators/undirected-graph-validator.cpp +32 -0
- testlib/validators/undirected-tree-validator.cpp +54 -0
- testlib/validators/validate-using-testset-and-group.cpp +31 -0
Lynx/__init__.py
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Copyright (c) 2023-present FredB-mine
|
|
2
|
+
|
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
# of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
# in the Software without restriction, including without limitation the rights
|
|
6
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
# furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
# The above copyright notice and this permission notice shall be included in all
|
|
11
|
+
# copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
19
|
+
# SOFTWARE.
|
|
20
|
+
|
|
21
|
+
import click
|
|
22
|
+
from Lynx.utils.constants import VERSION
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def print_version(ctx, param, value):
|
|
26
|
+
if not value or ctx.resilient_parsing:
|
|
27
|
+
return
|
|
28
|
+
click.echo(VERSION)
|
|
29
|
+
ctx.exit()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# register CLI group, must be placed before importing submodules
|
|
33
|
+
@click.group()
|
|
34
|
+
@click.option(
|
|
35
|
+
"--version",
|
|
36
|
+
is_flag=True,
|
|
37
|
+
is_eager=True,
|
|
38
|
+
expose_value=False,
|
|
39
|
+
callback=print_version,
|
|
40
|
+
help="Show the version of lynx.",
|
|
41
|
+
)
|
|
42
|
+
def cli():
|
|
43
|
+
"""lynx: Next generation testcase tool set for OI / ACM contests."""
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
import Lynx.modules.generate
|
|
48
|
+
import Lynx.modules.compare
|
|
49
|
+
import Lynx.modules.init
|
Lynx/modules/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# just for setuptools to find
|
Lynx/modules/compare.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import os
|
|
3
|
+
import Lynx.utils.config as config
|
|
4
|
+
|
|
5
|
+
from Lynx import cli
|
|
6
|
+
from Lynx.utils.language import cpp
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@cli.command()
|
|
10
|
+
@click.argument("problem", type=click.Path())
|
|
11
|
+
@click.argument("program1", type=click.File("r"))
|
|
12
|
+
@click.argument("program2", type=click.File("r"), required=False)
|
|
13
|
+
@click.option(
|
|
14
|
+
"--testcase", type=int, default=0, help="The index of the testcase to compare."
|
|
15
|
+
)
|
|
16
|
+
# checker will be supported in the future when cyaron implements it.
|
|
17
|
+
# @click.option(
|
|
18
|
+
# "--checker",
|
|
19
|
+
# is_flag=True,
|
|
20
|
+
# default=False,
|
|
21
|
+
# help="Use checker (special judge).",
|
|
22
|
+
# )
|
|
23
|
+
def compare(problem, program1, program2, testcase):
|
|
24
|
+
"""This command compares two programs using a lynx problem description.
|
|
25
|
+
|
|
26
|
+
PROBLEM is the lynx problem directory.
|
|
27
|
+
|
|
28
|
+
PROGRAM1 is the program to compare with.
|
|
29
|
+
|
|
30
|
+
PROGRAM2 is the second program to compare with, it is set to the standard solution to the problem by default.
|
|
31
|
+
"""
|
|
32
|
+
pass
|
Lynx/modules/generate.py
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import os
|
|
3
|
+
import random
|
|
4
|
+
import Lynx.utils.config as config
|
|
5
|
+
|
|
6
|
+
from cyaron import *
|
|
7
|
+
from Lynx import cli
|
|
8
|
+
from Lynx.utils.language import cpp
|
|
9
|
+
from Lynx.utils.constants import SUPPORTED_OJ
|
|
10
|
+
|
|
11
|
+
# Warning: This may cause security risks. We should try to replace it.
|
|
12
|
+
from importlib import import_module
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@cli.command()
|
|
16
|
+
@click.argument("problem", type=click.Path())
|
|
17
|
+
@click.option(
|
|
18
|
+
"--oj",
|
|
19
|
+
type=click.Choice(SUPPORTED_OJ),
|
|
20
|
+
default="hydro",
|
|
21
|
+
help="The online judge to upload the problem to, used when packing data.",
|
|
22
|
+
)
|
|
23
|
+
@click.option(
|
|
24
|
+
"--seed",
|
|
25
|
+
type=int,
|
|
26
|
+
required=False,
|
|
27
|
+
help="The random seed to specify (optional).",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--no-validate",
|
|
31
|
+
is_flag=True,
|
|
32
|
+
default=False,
|
|
33
|
+
help="Not to validate when generating data.",
|
|
34
|
+
)
|
|
35
|
+
def generate(problem, oj, seed, no_validate):
|
|
36
|
+
"""This command generates testcases of a lynx problem."""
|
|
37
|
+
# check if the problem directory exists
|
|
38
|
+
if seed is not None:
|
|
39
|
+
random.seed(seed) # Write unit tests for setting seed.
|
|
40
|
+
|
|
41
|
+
# maybe you forget to specify --no-validator?
|
|
42
|
+
pass
|
Lynx/modules/init.py
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import click
|
|
2
|
+
import os
|
|
3
|
+
import Lynx.utils.config as config
|
|
4
|
+
|
|
5
|
+
from Lynx import cli
|
|
6
|
+
from Lynx.utils.log import *
|
|
7
|
+
from Lynx.utils.language import cpp
|
|
8
|
+
from Lynx.utils.constants import CPP_STANDARDS, CHECKERS, VALIDATORS
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@cli.command()
|
|
12
|
+
@click.argument("problem", type=click.Path())
|
|
13
|
+
@click.option( # language
|
|
14
|
+
"--language",
|
|
15
|
+
default="c++14",
|
|
16
|
+
help="The language (standard) used when generating data.",
|
|
17
|
+
type=click.Choice(CPP_STANDARDS),
|
|
18
|
+
)
|
|
19
|
+
@click.option( # checker
|
|
20
|
+
"--checker",
|
|
21
|
+
type=click.Choice(CHECKERS),
|
|
22
|
+
default="custom",
|
|
23
|
+
help="Use a checker (special judge). You can specify the checker provided by testlib or use your customized checker by default.",
|
|
24
|
+
)
|
|
25
|
+
@click.option( # validator
|
|
26
|
+
"--validator",
|
|
27
|
+
type=click.Choice(VALIDATORS),
|
|
28
|
+
default="custom",
|
|
29
|
+
help="Use a validator. You can also use the validator provided by testlib in a similar way as the checker.",
|
|
30
|
+
)
|
|
31
|
+
@click.option("--testcase", type=int, default=20, help="The number of testcases.")
|
|
32
|
+
@click.option(
|
|
33
|
+
"--time-limit",
|
|
34
|
+
type=int,
|
|
35
|
+
default=1000,
|
|
36
|
+
help="The time limit of the problem, uses ms as unit.",
|
|
37
|
+
)
|
|
38
|
+
@click.option(
|
|
39
|
+
"--memory-limit",
|
|
40
|
+
type=int,
|
|
41
|
+
default=512,
|
|
42
|
+
help="The memory limit of the problem, uses MB as unit.",
|
|
43
|
+
)
|
|
44
|
+
# no checker
|
|
45
|
+
@click.option(
|
|
46
|
+
"--no-checker",
|
|
47
|
+
is_flag=True,
|
|
48
|
+
default=False,
|
|
49
|
+
help="Do not use a checker (special judge).",
|
|
50
|
+
)
|
|
51
|
+
def init(
|
|
52
|
+
problem,
|
|
53
|
+
language,
|
|
54
|
+
checker,
|
|
55
|
+
validator,
|
|
56
|
+
testcase,
|
|
57
|
+
time_limit,
|
|
58
|
+
memory_limit,
|
|
59
|
+
no_checker,
|
|
60
|
+
):
|
|
61
|
+
"""This command initializes a lynx problem directory."""
|
|
62
|
+
# Turn the problem path into an absolute path
|
|
63
|
+
if not os.path.isabs(problem):
|
|
64
|
+
problem = os.path.join(os.getcwd(), problem)
|
|
65
|
+
debug(f"problem route is {problem}")
|
|
66
|
+
if os.path.exists(problem):
|
|
67
|
+
error_and_exit(f"Problem directory {problem} already exists.")
|
|
68
|
+
if language in CPP_STANDARDS:
|
|
69
|
+
cpp.init_problem(
|
|
70
|
+
problem,
|
|
71
|
+
language,
|
|
72
|
+
checker,
|
|
73
|
+
validator,
|
|
74
|
+
testcase,
|
|
75
|
+
time_limit,
|
|
76
|
+
memory_limit,
|
|
77
|
+
no_checker,
|
|
78
|
+
)
|
|
79
|
+
else: # Other languages will be supported in the future
|
|
80
|
+
assert False # This should never happen
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This checker will be compiled into an executive,
|
|
3
|
+
* and the testcase-tools will provide it with the input
|
|
4
|
+
* file and the output file in a way that testlib recognizes.
|
|
5
|
+
*
|
|
6
|
+
* So you can use the built-in io functions in testlib.h
|
|
7
|
+
* to write your checker.
|
|
8
|
+
*/
|
|
9
|
+
#include "testlib.h"
|
|
10
|
+
|
|
11
|
+
int main(int argc, char *argv[]) {
|
|
12
|
+
registerTestlibCmd(argc, argv);
|
|
13
|
+
return 0;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Write your standard solution to the problem here.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This validator will be compiled into an executive,
|
|
3
|
+
* and the testcase-tools will provide it with the input
|
|
4
|
+
* file in a way that testlib recognizes.
|
|
5
|
+
*
|
|
6
|
+
* So you can use the built-in io functions in testlib.h
|
|
7
|
+
* to write your validator.
|
|
8
|
+
*
|
|
9
|
+
* You can just leave it empty if you don't need to check the output.
|
|
10
|
+
* Just remember to specify --no-validator when generating in that case.
|
|
11
|
+
*/
|
|
12
|
+
#include "testlib.h"
|
|
13
|
+
|
|
14
|
+
int main(int argc, char *argv[]) {
|
|
15
|
+
registerValidation(argc, argv);
|
|
16
|
+
return 0;
|
|
17
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# 题目类型,可以为 default(比对输出,可以含spj), objective(客观题), interactive(交互题)
|
|
2
|
+
type: default
|
|
3
|
+
|
|
4
|
+
# 全局时空限制(此处的限制优先级低于测试点的限制)
|
|
5
|
+
time: 1s
|
|
6
|
+
memory: 128m
|
|
7
|
+
|
|
8
|
+
# 输入输出文件名(例:使用 foo.in 和 foo.out),若使用标准 IO 删除此配置项即可
|
|
9
|
+
filename: foo
|
|
10
|
+
|
|
11
|
+
# 此部分设置当题目类型为 default 时生效
|
|
12
|
+
# 比较器类型,支持的值有 default(直接比对,忽略行末空格和文件末换行), ccr, cena, hustoj, lemon, qduoj, syzoj, testlib(比较常用)
|
|
13
|
+
checker_type: default
|
|
14
|
+
# 比较器文件(当比较器类型不为 default 时填写)
|
|
15
|
+
# 文件路径(位于压缩包中的路径)
|
|
16
|
+
# 将通过扩展名识别语言,与编译命令处一致。在默认配置下,C++ 扩展名应为 .cc 而非 .cpp
|
|
17
|
+
checker: chk.cc
|
|
18
|
+
|
|
19
|
+
# 此部分设置当题目类型为interactive时生效
|
|
20
|
+
# 交互器路径(位于压缩包中的路径)
|
|
21
|
+
interactor: interactor.cc
|
|
22
|
+
|
|
23
|
+
# Extra files 额外文件
|
|
24
|
+
# These files will be copied to the working directory 这些文件将被复制到工作目录。
|
|
25
|
+
# 提示:您无需手动上传 testlib.h。
|
|
26
|
+
user_extra_files:
|
|
27
|
+
- extra_input.txt
|
|
28
|
+
judge_extra_files:
|
|
29
|
+
- extra_file.txt
|
|
30
|
+
|
|
31
|
+
# Test Cases 测试数据列表
|
|
32
|
+
# If neither CASES or SUBTASKS are set(or config.yaml doesn't exist), judge will try to locate them automaticly.
|
|
33
|
+
# 如果 CASES 和 SUBTASKS 都没有设置或 config.yaml 不存在, 系统会自动尝试识别数据点。
|
|
34
|
+
# We support these names for auto mode: 自动识别支持以下命名方式:
|
|
35
|
+
# 1. [name(optional)][number].(in/out/ans) RegExp: /^([a-zA-Z]*)([0-9]+).in$/
|
|
36
|
+
# examples:
|
|
37
|
+
# - c1.in / c1.out
|
|
38
|
+
# - 1.in / 1.out
|
|
39
|
+
# - c1.in / c1.ans
|
|
40
|
+
# 2. input[number].txt / output[number].txt RegExp: /^(input)([0-9]+).txt$/
|
|
41
|
+
# - example: input1.txt / input2.txt
|
|
42
|
+
#
|
|
43
|
+
# The CASES option has higher priority than the SUBTASKS option!
|
|
44
|
+
# 在有 CASES 设置项时,不会读取 SUBTASKS 设置项!
|
|
45
|
+
#
|
|
46
|
+
# The CASES option has been deprecated in the new version, please use the more personalized SUBTASKS!
|
|
47
|
+
# CASES 已于新版本中被废弃,请使用个性化程度更高的SUBTASKS!
|
|
48
|
+
# score: 50 # 单个测试点分数
|
|
49
|
+
# time: 1s # 时间限制
|
|
50
|
+
# memory: 256m # 内存限制
|
|
51
|
+
# cases:
|
|
52
|
+
# - input: abc.in
|
|
53
|
+
# output: def.out
|
|
54
|
+
# - input: ghi.in
|
|
55
|
+
# output: jkl.out
|
|
56
|
+
# 或使用Subtask项:
|
|
57
|
+
subtasks:
|
|
58
|
+
- score: 30
|
|
59
|
+
type: min # 可选 min/max/sum,分别表示分数取所有测试点最小值、所有测试点最大值、所有测试点之和
|
|
60
|
+
time: 1s
|
|
61
|
+
memory: 64m
|
|
62
|
+
cases:
|
|
63
|
+
- time: 0.5s
|
|
64
|
+
memory: 32m # 可对单个测试点单独设置时间限制和内存限制
|
|
65
|
+
input: a.in
|
|
66
|
+
output: a.out
|
|
67
|
+
- input: b.in
|
|
68
|
+
output: b.out
|
|
69
|
+
- score: 70
|
|
70
|
+
time: 0.5s
|
|
71
|
+
memory: 32m
|
|
72
|
+
if: [0] # 可选,传入数组,表示仅在subtask0通过时此subtask才计分
|
|
73
|
+
cases:
|
|
74
|
+
- input: c.in
|
|
75
|
+
output: c.out
|
|
76
|
+
- input: d.in
|
|
77
|
+
output: d.out
|
|
78
|
+
|
|
79
|
+
# 提交语言限制
|
|
80
|
+
# 列举出所有本题允许使用的语言对应的代码(需要和评测机 lang.yaml 内的语言代码相同)
|
|
81
|
+
# 使用语言ID而非名称!对于有子类的选项,请详细至子分类!
|
|
82
|
+
langs:
|
|
83
|
+
- c
|
|
84
|
+
- cc
|
|
85
|
+
- cc.cc11o2
|
|
86
|
+
- pas
|
|
87
|
+
|
|
88
|
+
# 时间内存倍率
|
|
89
|
+
# 对某语言设置时间或内存倍率(需要和评测机 lang.yaml 内的语言代码相同)
|
|
90
|
+
# 部分语言默认已存在倍率,请前往控制面板中查看!
|
|
91
|
+
# 使用语言ID而非名称!对于有子类的选项,请详细至子分类!
|
|
92
|
+
time_limit_rate:
|
|
93
|
+
py.py3: 2
|
|
94
|
+
memory_limit_rate:
|
|
95
|
+
java: 1.5
|
Lynx/utils/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# just for setuptools to find
|
Lynx/utils/config.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import yaml
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Used to manage the range of variables more easily
|
|
6
|
+
# It will be replaced by some features of cyaron in the future.
|
|
7
|
+
class SubtaskManager: ...
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class CppProblemConfig:
|
|
11
|
+
def __init__(self, problem_path: str):
|
|
12
|
+
self.problem_path = problem_path
|
|
13
|
+
self.problem_config_path = os.path.join(problem_path, "problem.yaml")
|
|
14
|
+
self.testdata_config_path = os.path.join(
|
|
15
|
+
problem_path, "testdata", "config.yaml"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
def init_configs(
|
|
19
|
+
self, standard, testcase, time_limit, memory_limit, no_checker
|
|
20
|
+
): ...
|
Lynx/utils/constants.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import os
|
|
2
|
+
|
|
3
|
+
VERSION = "2.0.1b3"
|
|
4
|
+
|
|
5
|
+
# Some directories
|
|
6
|
+
LYNX_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
7
|
+
TESTLIB_ROOT = os.path.join(LYNX_ROOT, "..", "testlib")
|
|
8
|
+
TEMPLATES_ROOT = os.path.join(LYNX_ROOT, "templates")
|
|
9
|
+
CPP_TEMPLATES_ROOT = os.path.join(TEMPLATES_ROOT, "cpp")
|
|
10
|
+
|
|
11
|
+
# Standards
|
|
12
|
+
CPP_STANDARDS = ["c++98", "c++03", "c++11", "c++14", "c++17"]
|
|
13
|
+
|
|
14
|
+
# Testlib checkers and validators
|
|
15
|
+
CHECKERS = [
|
|
16
|
+
"custom",
|
|
17
|
+
"nyesno",
|
|
18
|
+
"ncmp",
|
|
19
|
+
"casencmp",
|
|
20
|
+
"lcmp",
|
|
21
|
+
"rncmp",
|
|
22
|
+
"yesno",
|
|
23
|
+
"dcmp",
|
|
24
|
+
"hcmp",
|
|
25
|
+
"pointscmp",
|
|
26
|
+
"rcmp",
|
|
27
|
+
"fcmp",
|
|
28
|
+
"rcmp9",
|
|
29
|
+
"rcmp4",
|
|
30
|
+
"wcmp",
|
|
31
|
+
"rcmp6",
|
|
32
|
+
".gitignore",
|
|
33
|
+
"casewcmp",
|
|
34
|
+
"acmp",
|
|
35
|
+
"icmp",
|
|
36
|
+
"pointsinfo",
|
|
37
|
+
"uncmp",
|
|
38
|
+
"caseicmp",
|
|
39
|
+
]
|
|
40
|
+
VALIDATORS = [
|
|
41
|
+
"custom",
|
|
42
|
+
"validate-using-testset-and-group",
|
|
43
|
+
"undirected-graph-validator",
|
|
44
|
+
"bipartite-graph-validator",
|
|
45
|
+
"nval",
|
|
46
|
+
"undirected-tree-validator",
|
|
47
|
+
"sval",
|
|
48
|
+
"ival",
|
|
49
|
+
"case-nval",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
SUPPORTED_OJ = ["luogu", "hydro", "qdu"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# just for setuptools to find.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import shutil
|
|
3
|
+
|
|
4
|
+
from Lynx.utils.log import *
|
|
5
|
+
from Lynx.utils.constants import *
|
|
6
|
+
from Lynx.utils.config import CppProblemConfig
|
|
7
|
+
|
|
8
|
+
"""The structure of a problem directory is as follows:
|
|
9
|
+
.
|
|
10
|
+
├── {problem_path}
|
|
11
|
+
│ ├── problem.yaml
|
|
12
|
+
│ ├── problem_zh.md
|
|
13
|
+
│ ├── testdata
|
|
14
|
+
│ │ ├── config.yaml
|
|
15
|
+
│ │ ├── a1.in
|
|
16
|
+
│ │ └── a1.out
|
|
17
|
+
│ └── additional_file
|
|
18
|
+
│ ├── a.png
|
|
19
|
+
│ └── b.pdf
|
|
20
|
+
└── ...
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def init_problem(
|
|
25
|
+
problem_path: str,
|
|
26
|
+
standard: str,
|
|
27
|
+
checker: str,
|
|
28
|
+
validator: str,
|
|
29
|
+
testcase: int,
|
|
30
|
+
time_limit: int,
|
|
31
|
+
memory_limit: int,
|
|
32
|
+
no_checker: bool,
|
|
33
|
+
):
|
|
34
|
+
shutil.copytree(CPP_TEMPLATES_ROOT, problem_path)
|
|
35
|
+
shutil.copyfile(
|
|
36
|
+
os.path.join(TEMPLATES_ROOT, "generator.py"),
|
|
37
|
+
os.path.join(problem_path, "programs", "generator.py"),
|
|
38
|
+
)
|
|
39
|
+
os.remove(os.path.join(problem_path, "additional_file", ".gitkeep"))
|
|
40
|
+
if checker != "custom":
|
|
41
|
+
shutil.copy2(
|
|
42
|
+
os.path.join(TESTLIB_ROOT, "checkers", f"{checker}.cpp"),
|
|
43
|
+
os.path.join(problem_path, "programs", "checker.cpp"),
|
|
44
|
+
)
|
|
45
|
+
if validator != "custom":
|
|
46
|
+
shutil.copy2(
|
|
47
|
+
os.path.join(TESTLIB_ROOT, "validators", f"{validator}.cpp"),
|
|
48
|
+
os.path.join(problem_path, "programs", "validator.cpp"),
|
|
49
|
+
)
|
|
50
|
+
config = CppProblemConfig(problem_path)
|
|
51
|
+
config.init_configs(standard, testcase, time_limit, memory_limit, no_checker)
|
Lynx/utils/log.py
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import click
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def error(message: str) -> None:
|
|
5
|
+
"""Print an error message."""
|
|
6
|
+
click.echo(click.style(f"ERROR: {message}", fg="red"))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def error_and_exit(message: str, code: int = 1) -> None:
|
|
10
|
+
"""Print an error message and exit."""
|
|
11
|
+
error(message)
|
|
12
|
+
raise click.exceptions.Exit(code)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def debug(message: str) -> None:
|
|
16
|
+
"""Print a debug message."""
|
|
17
|
+
click.echo(click.style(f"DEBUG: {message}", fg="blue"))
|