diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index cd6cffb1f..c33c8e84c 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.5.15", + "version": "2.5.16", "main": "package.json", "author": "undefined ", "repository": "https://github.com/hydro-dev/Hydro.git", diff --git a/packages/hydrojudge/setting.yaml b/packages/hydrojudge/setting.yaml index 348ee63b5..6fede66ee 100644 --- a/packages/hydrojudge/setting.yaml +++ b/packages/hydrojudge/setting.yaml @@ -98,6 +98,7 @@ langs: code_file: Main.java target: Main.class execute: /usr/bin/java Main + time_limit_rate: 2 py: type: compiler compile: /usr/bin/python -c "import py_compile; py_compile.compile('${dir}/foo.py', '${dir}/${name}', doraise=True)" diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index 959f0a2a3..f6f638aff 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -1,5 +1,6 @@ import Queue from 'p-queue'; import path from 'path'; +import yaml from 'js-yaml'; import fs from 'fs-extra'; import { argv } from 'yargs'; import * as STATUS from '../status'; @@ -102,6 +103,7 @@ function judgeCase(c, sid) { function judgeSubtask(subtask, sid) { return async (ctx) => { + subtask.time *= ctx.time_limit_rate; subtask.type = subtask.type || 'min'; const ctxSubtask = { subtask, @@ -132,6 +134,10 @@ export const judge = async (ctx) => { ctx.code = tpl[0] + ctx.code + tpl[1]; } else throw new CompileError('Language not supported by provided templates'); } + const LANGS = yaml.load(getConfig('langs')); + if (!LANGS[ctx.lang]) throw new SystemError('Unsupported language {0}.', [ctx.lang]); + const info = LANGS[ctx.lang]; + ctx.time_limit_rate = info.time_limit_rate || 1; ctx.next({ status: STATUS.STATUS_COMPILING }); [ctx.execute, ctx.checker] = await Promise.all([ (async () => { diff --git a/packages/hydrojudge/src/judge/interactive.ts b/packages/hydrojudge/src/judge/interactive.ts index 6720c1751..1794c89b1 100644 --- a/packages/hydrojudge/src/judge/interactive.ts +++ b/packages/hydrojudge/src/judge/interactive.ts @@ -1,6 +1,7 @@ import Queue from 'p-queue'; import fs from 'fs-extra'; import { argv } from 'yargs'; +import yaml from 'js-yaml'; import * as STATUS from '../status'; import { parse } from '../testlib'; import { findFileSync, parseFilename } from '../utils'; @@ -8,6 +9,7 @@ import { run } from '../sandbox'; import compile from '../compile'; import signals from '../signals'; import { getConfig } from '../config'; +import { SystemError } from '../error'; const testlibSrc = findFileSync('@hydrooj/hydrojudge/vendor/testlib/testlib.h'); const Score = { @@ -70,6 +72,7 @@ function judgeCase(c) { function judgeSubtask(subtask) { return async (ctx) => { + subtask.time *= ctx.time_limit_rate; subtask.type = subtask.type || 'min'; const ctxSubtask = { subtask, @@ -90,6 +93,10 @@ function judgeSubtask(subtask) { export const judge = async (ctx) => { ctx.next({ status: STATUS.STATUS_COMPILING }); + const LANGS = yaml.load(getConfig('langs')); + if (!LANGS[ctx.lang]) throw new SystemError('Unsupported language {0}.', [ctx.lang]); + const info = LANGS[ctx.lang]; + ctx.time_limit_rate = info.time_limit_rate || 1; [ctx.executeUser, ctx.executeInteractor] = await Promise.all([ (async () => { const copyIn = {};