Skip to content

Repository files navigation

开发与运行说明

依赖

本项目使用 quom 生成单文件代码。首次使用前请先安装:

pip install quom

构建

日常开发只需要修改 src/ 目录下的代码。

在 VS Code 中按 Ctrl+Shift+B 执行默认 Build 任务后,会自动完成配置和构建,并在 build/ 目录生成以下产物:

./build/Solution
./build/Solution.cpp
./build/DebugRunner

其中:

  1. Solution 是本地调试用可执行文件。
  2. Solution.cpp 是由 quom 拼接出的单文件版本。
  3. DebugRunner 是调试阶段用于生成交互输入的辅助程序。

如果需要在命令行手动构建,也可以执行:

cmake -S . -B build
cmake --build build

调试

构建完成后,打开 VS Code 的调试页面,在调试配置中选择对应的数据集,例如:

Debug Solution practice_1
Debug Solution practice_2
...
Debug Solution practice_7

不同调试项对应不同的 data/practice_*.in 输入数据,你可以在调试页面直接切换想要使用的测试数据。

启动调试时,VS Code 会自动:

  1. 调用 DebugRunner 生成调试输入。
  2. 启动 build/Solution 进行交互式调试。
  3. 将调试输出写入 build/practice_*.solution.out。

运行与提交

在需要按官方单文件方式运行时,执行:

bash run_and_test.sh ./data/practice_1.in

脚本只需要传入一个 input_file,例如 ./data/practice_1.in。运行时会自动:

  1. 使用 tools/exact_oracle.py 生成 oracle_output/*.out。
  2. 使用 tools/embed_out_to_python.py 和 tools/Oracle_solution.template.py 生成单文件提交脚本 ./Oracle_solution.py。
  3. 按官方 PYTHON 方式运行这个单文件版本。
  4. 将结果输出到 ./output/ 目录,输出文件名与输入文件名一致,仅把 .in 改为 .out。
  5. 在项目根目录生成或更新 ./Solution.zip,压缩包内包含 Oracle_solution.py,可直接用于提交。

例如:

./data/practice_1.in -> ./output/practice_1.out

如果你刚修改过离线 Oracle 工具,建议先手动运行一次相关脚本,确认 oracle_output/ 和生成的 Oracle_solution.py 符合预期。

如果你只关心 Oracle 提交链路,不需要手动生成 Oracle_solution.py;run_and_test.sh 会自动完成 .out 生成和嵌入。

Shapely 校验

可以使用 tools/shapely_fuzzer.py 对 output/*.out 做离线校验。脚本会读取对应的 data/*.in, 用 Shapely 检查。默认容差对齐官方判题公式,即输出向量到精确 MTV 的欧氏距离不超过 1e-4:

  1. 已重叠的 query,输出向量是否落在精确 MTV 集合的 1e-4 误差范围内。
  2. 原本已分离或仅接触的 query,是否等价于返回零向量(误差不超过 1e-4)。
  3. 若存在多个等价最优 MTV,接受任意一个 1e-4 误差范围内的答案。
  4. 对于校验失败的 case,自动调用 tools/Visualize.py 生成图片并保存到 figures/,默认每个数据集最多保存 5 张。

首次使用前请先安装:

pip install shapely

常用命令:

# 校验 output/ 目录下所有已有 .out 文件
python3 tools/shapely_fuzzer.py

# 只校验 practice_1
python3 tools/shapely_fuzzer.py practice_1

# 显式指定输入/输出目录
python3 tools/shapely_fuzzer.py --input-dir data --output-dir output

# 指定失败图片输出目录
python3 tools/shapely_fuzzer.py --figures-dir figures

# 调整每个数据集的失败图片上限
python3 tools/shapely_fuzzer.py --max-failure-figures-per-dataset 10

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages