mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
judge: 限制总评测时间为60s
This commit is contained in:
1 parent
bd9eccdc1c
commit
c553f204ad
2 files changed
+11
-2
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.1.16",
|
"version": "2.1.17",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "masnn",
|
"author": "masnn",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -284,6 +284,15 @@ function convertIniConfig(ini: string) {
|
|||||||
return res;
|
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<string, any> = {}, args) {
|
export default async function readCases(folder: string, cfg: Record<string, any> = {}, args) {
|
||||||
const iniConfig = path.resolve(folder, 'config.ini');
|
const iniConfig = path.resolve(folder, 'config.ini');
|
||||||
const yamlConfig = path.resolve(folder, 'config.yaml');
|
const yamlConfig = path.resolve(folder, 'config.yaml');
|
||||||
@@ -294,6 +303,6 @@ export default async function readCases(folder: string, cfg: Record<string, any>
|
|||||||
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg };
|
config = { ...convertIniConfig(fs.readFileSync(iniConfig).toString()), ...cfg };
|
||||||
}
|
}
|
||||||
const result = await readYamlCases(folder, config, args);
|
const result = await readYamlCases(folder, config, args);
|
||||||
if (result.count > 100) throw new FormatError('测试数据组数过多,拒绝评测');
|
isValidConfig(result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user