From 1fc4b9afd2710803145b6618c2943842588f1074 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Sun, 5 Feb 2023 10:24:14 +0800 Subject: [PATCH] fix(judger): wrong final score when subtask scores are not all configured --- judger/uoj_judger/include/uoj_judger.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/judger/uoj_judger/include/uoj_judger.h b/judger/uoj_judger/include/uoj_judger.h index 600e806..2f8bcb9 100644 --- a/judger/uoj_judger/include/uoj_judger.h +++ b/judger/uoj_judger/include/uoj_judger.h @@ -1681,9 +1681,30 @@ bool main_data_test(TP test_point_func) { } } } else { // subtask + map subtask_metas; + score_t remaining_subtasks_total_score = 100; + int remaining_subtasks_cnt = nT; + + for (int t = 1; t <= nT; t++) { + score_t subtask_score = conf_score("subtask_score", t, -1); + + subtask_metas[t] = conf_subtask_meta_info(t); + subtask_metas[t].full_score = subtask_score; + + if (subtask_score != -1) { + remaining_subtasks_total_score -= subtask_score; + remaining_subtasks_cnt--; + } + } + map subtasks; for (int t = 1; t <= nT; t++) { - SubtaskInfo st_info(conf_subtask_meta_info(t)); + if (subtask_metas[t].full_score == -1) { + subtask_metas[t].full_score = remaining_subtasks_total_score / remaining_subtasks_cnt; + } + + SubtaskInfo st_info(subtask_metas[t]); + if (!st_info.resolve_dependencies(subtasks)) { st_info.info = "Skipped"; } else { @@ -1696,6 +1717,7 @@ bool main_data_test(TP test_point_func) { } } } + subtasks[t] = st_info; passed = passed && st_info.passed; add_subtask_info(st_info);