judge: fix subtask id handler

This commit is contained in:
undefined committed 2022-10-19 21:06:38 +08:00
1 parent e027b74f2d
commit 87c8eb060c
2 files changed
+10 -6

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": "3.1.2", "version": "3.1.3",
"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",
+9 -5
View File
@@ -100,15 +100,19 @@ export const runFlow = async (ctx: Context, task: Task) => {
ctx.end({ nop: true }); ctx.end({ nop: true });
} }
} else { } else {
const tasks = []; const scores = {};
for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid], sid, task.judgeCase)(ctx)); await Promise.all(Object.entries(ctx.config.subtasks).map(async ([key, value]) => {
const scores = await Promise.all(tasks); const sid = value.id?.toString() || key;
for (const sid in ctx.config.subtasks) { scores[sid] = await judgeSubtask(value, sid, task.judgeCase)(ctx);
}));
for (const [key, value] of Object.entries(ctx.config.subtasks)) {
let effective = true; let effective = true;
for (const required of ctx.config.subtasks[sid].if || []) { const sid = value.id?.toString() || key;
for (const required of value.if || []) {
if (ctx.failed[required.toString()]) effective = false; if (ctx.failed[required.toString()]) effective = false;
} }
if (effective) ctx.total_score += scores[sid]; if (effective) ctx.total_score += scores[sid];
else ctx.failed[sid] = true;
} }
ctx.end({ ctx.end({
status: ctx.total_status, status: ctx.total_status,