diff --git a/packages/hydrojudge/src/judge/objective.ts b/packages/hydrojudge/src/judge/objective.ts index cd3f50a7..9bc9a0b7 100644 --- a/packages/hydrojudge/src/judge/objective.ts +++ b/packages/hydrojudge/src/judge/objective.ts @@ -29,6 +29,7 @@ export async function judge({ } let totalScore = 0; let totalStatus = 0; + const subtasks = {}; if (!Object.keys(config.answers).length) throw new FormatError('Invalid standard answer.'); for (const key in config.answers) { const ansInfo = config.answers[key] as [string | string[], number] | Record; @@ -37,6 +38,11 @@ export async function judge({ const [subtaskId, caseId] = key.split('-').map(Number); totalScore += score; totalStatus = Math.max(totalStatus, status); + subtasks[subtaskId] ||= { score, status }; + if (subtasks[subtaskId].status && caseId) { + subtasks[subtaskId].score += score; + subtasks[subtaskId].status = Math.max(subtasks[subtaskId].status, status); + } next({ status: totalStatus, case: { @@ -59,9 +65,10 @@ export async function judge({ const fullScore = (+ansInfo[1]) || 0; const stdAns = ansInfo[0]; if (stdAns instanceof Array) { + const stdSet = new Set(stdAns); const ans = new Set(answers[key] instanceof Array ? answers[key] : [answers[key]]); - if (stdAns.length === ans.size && Set.isSuperset(ans, stdAns)) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct'); - else if (ans.size && Set.isSuperset(ans, stdAns)) report(STATUS.STATUS_WRONG_ANSWER, Math.floor(fullScore / 2), 'Partially Correct'); + if (stdAns.length === ans.size && Set.isSuperset(stdSet, ans)) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct'); + else if (ans.size && Set.isSuperset(stdSet, ans)) report(STATUS.STATUS_WRONG_ANSWER, Math.floor(fullScore / 2), 'Partially Correct'); else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect'); } else if (stdAns.toString() === usrAns) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct'); else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect'); @@ -69,7 +76,7 @@ export async function judge({ else report(STATUS.STATUS_ACCEPTED, +ansInfo[usrAns] || 0, 'Correct'); } end({ - status: totalStatus, score: totalScore, time: 0, memory: 0, + status: totalStatus, score: totalScore, time: 0, memory: 0, subtasks, }); return null; } diff --git a/packages/ui-default/templates/record_detail_status.html b/packages/ui-default/templates/record_detail_status.html index 7b3e228b..e6a9fcd2 100644 --- a/packages/ui-default/templates/record_detail_status.html +++ b/packages/ui-default/templates/record_detail_status.html @@ -71,7 +71,7 @@ {{ model.builtin.STATUS_TEXTS[rcdoc['status']] }} - {% if (_key != 'id' and rcdocs.length == 1) or (_key == 'id' and rdoc.subtasks[rcdoc.subtaskId].type == 'sum') %} + {% if (rdoc.subtask && _key != 'id' and rcdocs.length == 1 ) or (_key == 'id' and rdoc.subtasks[rcdoc.subtaskId].type == 'sum') %} {{ (rdoc.subtasks[subtaskId]['score'] if _key != 'id' else rcdoc.score)|default(0) }}