From 87c8eb060cbc1ec63834bba4a232203501265b61 Mon Sep 17 00:00:00 2001 From: undefined Date: Wed, 19 Oct 2022 21:06:38 +0800 Subject: [PATCH] judge: fix subtask id handler --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/flow.ts | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index a80f2a6cd..56dbc5809 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "3.1.2", + "version": "3.1.3", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/flow.ts b/packages/hydrojudge/src/flow.ts index 699b3e858..f88fed74b 100644 --- a/packages/hydrojudge/src/flow.ts +++ b/packages/hydrojudge/src/flow.ts @@ -100,15 +100,19 @@ export const runFlow = async (ctx: Context, task: Task) => { ctx.end({ nop: true }); } } else { - const tasks = []; - for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid], sid, task.judgeCase)(ctx)); - const scores = await Promise.all(tasks); - for (const sid in ctx.config.subtasks) { + const scores = {}; + await Promise.all(Object.entries(ctx.config.subtasks).map(async ([key, value]) => { + const sid = value.id?.toString() || key; + scores[sid] = await judgeSubtask(value, sid, task.judgeCase)(ctx); + })); + for (const [key, value] of Object.entries(ctx.config.subtasks)) { 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 (effective) ctx.total_score += scores[sid]; + else ctx.failed[sid] = true; } ctx.end({ status: ctx.total_status,