judge: enhance validation for communication type config (#1163)

This commit is contained in:
Heran Yang authored and GitHub committed 2026-05-16 04:04:57 +08:00
1 parent 5344268f1f
commit c5fed869e4
1 file changed
+8 -3
+8 -3
View File
@@ -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.');