From f51d94edcaf89939f55550add918aeb1fbaa0554 Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 29 Jun 2022 12:24:17 +0800 Subject: [PATCH] judge: objective: allow empty answers --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/judge/objective.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index d9bf6181..9dda2098 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.21.0", + "version": "2.21.1", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/judge/objective.ts b/packages/hydrojudge/src/judge/objective.ts index 0ac58849..729fb4ea 100644 --- a/packages/hydrojudge/src/judge/objective.ts +++ b/packages/hydrojudge/src/judge/objective.ts @@ -39,7 +39,7 @@ export async function judge({ memory: 0, }; if (typeof ansInfo[0] === 'string') { - if (ansInfo[0].trim() === (answers[key] as any).trim()) { + if (ansInfo[0]?.trim() === (answers[key] as any)?.trim()) { totalScore += score; totalStatus = Math.max(totalStatus, STATUS.STATUS_ACCEPTED); next({ @@ -64,8 +64,8 @@ export async function judge({ }, +caseId); } } else { - const stdAns = new Set(ansInfo[0]); - const ans = new Set(answers[key]); + const stdAns = new Set(ansInfo[0] || []); + const ans = new Set(answers[key] || []); const correct = stdAns.size === ans.size && [...stdAns].every((x) => ans.has(x)); const partialCorrect = [...stdAns].some((x) => ans.has(x)) && [...ans].every((x) => stdAns.has(x)); if (correct) {