Skip to content

Commit c5fed86

Browse files
authored
judge: enhance validation for communication type config (#1163)
1 parent 5344268 commit c5fed86

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/hydrojudge/src/cases.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,19 @@ function isValidConfig(config) {
1515
if (config.type !== 'objective' && config.count > (getConfig('testcases_max') || 100)) {
1616
throw new FormatError('Too many testcases. Cancelled.');
1717
}
18+
if (config.type === 'communication') {
19+
if (!Number.isInteger(config.num_processes) || config.num_processes <= 0) {
20+
throw new FormatError('Number of processes must be a positive integer for communication type.');
21+
}
22+
if (config.num_processes > getConfig('processLimit')) {
23+
throw new FormatError('Number of processes larger than processLimit');
24+
}
25+
}
1826
const time = (config.num_processes || 1) * Math.sum(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.time)));
1927
if (time > (getConfig('total_time_limit') || 60) * 1000) {
2028
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+getConfig('total_time_limit') || 60]);
2129
}
2230
const memMax = Math.max(...config.subtasks.flatMap((subtask) => subtask.cases.map((c) => c.memory)));
23-
if (config.type === 'communication' && (config.num_processes || 2) > getConfig('processLimit')) {
24-
throw new FormatError('Number of processes larger than processLimit');
25-
}
2631
if (memMax > parseMemoryMB(getConfig('memoryMax'))) throw new FormatError('Memory limit larger than memory_max');
2732
if (!['default', 'strict'].includes(config.checker_type || 'default') && !config.checker) {
2833
throw new FormatError('You did not specify a checker.');

0 commit comments

Comments
 (0)