From c5fed869e448c213639e6125df29d294181f39a7 Mon Sep 17 00:00:00 2001 From: Heran Yang Date: Sat, 16 May 2026 04:04:57 +0800 Subject: [PATCH] judge: enhance validation for communication type config (#1163) --- packages/hydrojudge/src/cases.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index ce7cb3987..3d5d08ba9 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -15,14 +15,19 @@ function isValidConfig(config) { if (config.type !== 'objective' && config.count > (getConfig('testcases_max') || 100)) { throw new FormatError('Too many testcases. Cancelled.'); } + if (config.type === 'communication') { + if (!Number.isInteger(config.num_processes) || config.num_processes <= 0) { + throw new FormatError('Number of processes must be a positive integer for communication type.'); + } + if (config.num_processes > getConfig('processLimit')) { + throw new FormatError('Number of processes larger than processLimit'); + } + } const time = (config.num_processes || 1) * Math.sum(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.time))); if (time > (getConfig('total_time_limit') || 60) * 1000) { throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+getConfig('total_time_limit') || 60]); } const memMax = Math.max(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.memory))); - if (config.type === 'communication' && (config.num_processes || 2) > getConfig('processLimit')) { - throw new FormatError('Number of processes larger than processLimit'); - } if (memMax > parseMemoryMB(getConfig('memoryMax'))) throw new FormatError('Memory limit larger than memory_max'); if (!['default', 'strict'].includes(config.checker_type || 'default') && !config.checker) { throw new FormatError('You did not specify a checker.');