From 80f54249d36e24473bcb5ddb3889096265c37c68 Mon Sep 17 00:00:00 2001 From: ZnPdCo <66149312+ZnPdCo@users.noreply.github.com> Date: Sat, 16 May 2026 20:04:56 +0800 Subject: [PATCH 1/2] feat(interactive-problems.md): Clarified checker.cpp should registered as Interaction --- docs/manual/luogu/problem/interactive-problems.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/manual/luogu/problem/interactive-problems.md b/docs/manual/luogu/problem/interactive-problems.md index 6637bb0..85f6336 100644 --- a/docs/manual/luogu/problem/interactive-problems.md +++ b/docs/manual/luogu/problem/interactive-problems.md @@ -62,7 +62,7 @@ int main() { ### 需要使用 SPJ 的情况 -事实上,大部分函数式交互题目并不像上例那么简单。以 [P13612 [IOI 2018] combo 组合动作](https://www.luogu.com.cn/problem/P13612) 为例,本题需要选手实现函数 `string guess_sequence(int N)`,允许选手调用函数 `int press(string p)`,且根据函数调用次数反馈评分。这个时候需要用到 Special Judge 功能。在文件目录下需要 interactive_lib.cpp 和 checker.cpp,并且同时勾选交互题和 Special Judge 标签。 +事实上,大部分函数式交互题目并不像上例那么简单。以 [P13612 [IOI 2018] combo 组合动作](https://www.luogu.com.cn/problem/P13612) 为例,本题需要选手实现函数 `string guess_sequence(int N)`,允许选手调用函数 `int press(string p)`,且根据函数调用次数反馈评分。这个时候需要用到 Special Judge 功能。在文件目录下需要 interactive_lib.cpp 和 checker.cpp,并且同时勾选交互题和 Special Judge 标签。同时,checker.cpp 需要注册为 Interaction。 在此类情况下,测试数据在 checker、interactive_lib 的流转如下: - 从 checker 的 inf 流读取试题原本的测试数据,再使用 stdout 输出信息。 @@ -190,4 +190,4 @@ int main(int argc, char **argv) { 1. 缓冲区问题。C/C++ 语言的输入输出函数均自带有一定的缓冲区,因此你输出的内容不一定能立刻被交互库/SPJ 所读取。如果不在合适的时间清空缓冲区,很可能会造成两个程序互相等待对方输出的情况而 TLE。 2. 每次输出完一定内容、希望对面的程序开始进行处理时,都必须手动清空缓冲区。在 C 语言中,可使用 `fflush(stdout)` 函数。在 C++ 语言中,可使用 `std::cout << std::flush` ;在使用 `std::endl` 输出一个换行时,C++ 语言也会自动清空缓冲区。 -3. 交互库(以及 SPJ)最好不要占用太多的 CPU 资源,因为它将与用户的程序在同一个核心上执行。最好在评测程序等待来自 SPJ 的输入,或者评测程序已经结束运行之后,再进行复杂的计算。 \ No newline at end of file +3. 交互库(以及 SPJ)最好不要占用太多的 CPU 资源,因为它将与用户的程序在同一个核心上执行。最好在评测程序等待来自 SPJ 的输入,或者评测程序已经结束运行之后,再进行复杂的计算。 From 0091605251002a87b301b46fa7eae4b53f4f42a9 Mon Sep 17 00:00:00 2001 From: ZnPdCo <66149312+ZnPdCo@users.noreply.github.com> Date: Sat, 16 May 2026 20:08:38 +0800 Subject: [PATCH 2/2] Remove enter