Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions packages/hydrojudge/src/cases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.');
Expand Down
Loading