From c553f204adb0d56b8573610401f85fde49200b31 Mon Sep 17 00:00:00 2001 From: undefined Date: Sat, 31 Oct 2020 10:58:29 +0800 Subject: [PATCH] =?UTF-8?q?judge:=20=E9=99=90=E5=88=B6=E6=80=BB=E8=AF=84?= =?UTF-8?q?=E6=B5=8B=E6=97=B6=E9=97=B4=E4=B8=BA60s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/hydrojudge/package.json | 2 +- packages/hydrojudge/src/cases.ts | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index b27d1ba71..2e1341167 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.1.16", + "version": "2.1.17", "main": "package.json", "author": "masnn", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/src/cases.ts b/packages/hydrojudge/src/cases.ts index 95bde7627..6e92d3a8c 100644 --- a/packages/hydrojudge/src/cases.ts +++ b/packages/hydrojudge/src/cases.ts @@ -284,6 +284,15 @@ function convertIniConfig(ini: string) { return res; } +function isValidConfig(config) { + if (config.count > 100) throw new FormatError('测试数据组数过多,拒绝评测'); + let total_time = 0; + for (const subtask of config.subtasks) { + total_time += subtask.time_limit_ms * subtask.cases.length; + } + if (total_time > 60 * 1000) throw new FormatError('总时限超过限制60s,拒绝评测'); +} + export default async function readCases(folder: string, cfg: Record = {}, args) { const iniConfig = path.resolve(folder, 'config.ini'); const yamlConfig = path.resolve(folder, 'config.yaml'); @@ -294,6 +303,6 @@ export default async function readCases(folder: string, cfg: Record config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg }; } const result = await readYamlCases(folder, config, args); - if (result.count > 100) throw new FormatError('测试数据组数过多,拒绝评测'); + isValidConfig(result); return result; }