mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: better config validate
This commit is contained in:
1 parent
68286607e9
commit
5dd5dca675
3 files changed
+5
-7
No files matched your search
@@ -7,7 +7,7 @@
|
|||||||
"author": "undefined <masnn0@outlook.com>",
|
"author": "undefined <masnn0@outlook.com>",
|
||||||
"license": "AGPL-3.0-only",
|
"license": "AGPL-3.0-only",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nodejieba": "^2.4.2"
|
"nodejieba": "^2.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import yaml from 'js-yaml';
|
import yaml from 'js-yaml';
|
||||||
import { Dictionary } from 'lodash';
|
import { Dictionary, sum } from 'lodash';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
import { FormatError, SystemError } from './error';
|
import { FormatError, SystemError } from './error';
|
||||||
import { parseTimeMS, parseMemoryMB, ensureFile } from './utils';
|
import { parseTimeMS, parseMemoryMB, ensureFile } from './utils';
|
||||||
@@ -285,11 +285,10 @@ function convertIniConfig(ini: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isValidConfig(config) {
|
function isValidConfig(config) {
|
||||||
if (config.count > (argv.max_testcases_count as string || 100)) throw new FormatError('Too many testcases. Cancelled.');
|
if (config.count > (argv.max_testcases_count as string || 100)) {
|
||||||
let total_time = 0;
|
throw new FormatError('Too many testcases. Cancelled.');
|
||||||
for (const subtask of config.subtasks) {
|
|
||||||
total_time += subtask.time_limit_ms * subtask.cases.length;
|
|
||||||
}
|
}
|
||||||
|
const total_time = sum(config.subtasks.map((subtask) => subtask.time_limit_ms * subtask.cases.length));
|
||||||
if (total_time > (+argv.max_time_limit || 60) * 1000) {
|
if (total_time > (+argv.max_time_limit || 60) * 1000) {
|
||||||
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+argv.max_time_limit || 60]);
|
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+argv.max_time_limit || 60]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import { ObjectID, FilterQuery } from 'mongodb';
|
import { ObjectID, FilterQuery } from 'mongodb';
|
||||||
import { filter, sortBy } from 'lodash';
|
|
||||||
import * as user from './user';
|
import * as user from './user';
|
||||||
import * as problem from './problem';
|
import * as problem from './problem';
|
||||||
import * as document from './document';
|
import * as document from './document';
|
||||||
|
|||||||
Reference in new issue
Block a user