judge: objective: allow empty answers

This commit is contained in:
undefined committed 2022-06-29 12:24:17 +08:00
1 parent 3cfbb66350
commit f51d94edca
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.21.0", "version": "2.21.1",
"main": "package.json", "main": "package.json",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git", "repository": "https://github.com/hydro-dev/Hydro.git",
+3 -3
View File
@@ -39,7 +39,7 @@ export async function judge({
memory: 0, memory: 0,
}; };
if (typeof ansInfo[0] === 'string') { 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; totalScore += score;
totalStatus = Math.max(totalStatus, STATUS.STATUS_ACCEPTED); totalStatus = Math.max(totalStatus, STATUS.STATUS_ACCEPTED);
next({ next({
@@ -64,8 +64,8 @@ export async function judge({
}, +caseId); }, +caseId);
} }
} else { } else {
const stdAns = new Set(ansInfo[0]); const stdAns = new Set(ansInfo[0] || []);
const ans = new Set(answers[key]); const ans = new Set(answers[key] || []);
const correct = stdAns.size === ans.size && [...stdAns].every((x) => ans.has(x)); 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)); const partialCorrect = [...stdAns].some((x) => ans.has(x)) && [...ans].every((x) => stdAns.has(x));
if (correct) { if (correct) {