mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: java用户两倍时限
This commit is contained in:
1 parent
3664df4202
commit
c65fddfb76
4 files changed
+15
-1
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.5.15",
|
"version": "2.5.16",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ langs:
|
|||||||
code_file: Main.java
|
code_file: Main.java
|
||||||
target: Main.class
|
target: Main.class
|
||||||
execute: /usr/bin/java Main
|
execute: /usr/bin/java Main
|
||||||
|
time_limit_rate: 2
|
||||||
py:
|
py:
|
||||||
type: compiler
|
type: compiler
|
||||||
compile: /usr/bin/python -c "import py_compile; py_compile.compile('${dir}/foo.py', '${dir}/${name}', doraise=True)"
|
compile: /usr/bin/python -c "import py_compile; py_compile.compile('${dir}/foo.py', '${dir}/${name}', doraise=True)"
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import Queue from 'p-queue';
|
import Queue from 'p-queue';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
import * as STATUS from '../status';
|
import * as STATUS from '../status';
|
||||||
@@ -102,6 +103,7 @@ function judgeCase(c, sid) {
|
|||||||
|
|
||||||
function judgeSubtask(subtask, sid) {
|
function judgeSubtask(subtask, sid) {
|
||||||
return async (ctx) => {
|
return async (ctx) => {
|
||||||
|
subtask.time *= ctx.time_limit_rate;
|
||||||
subtask.type = subtask.type || 'min';
|
subtask.type = subtask.type || 'min';
|
||||||
const ctxSubtask = {
|
const ctxSubtask = {
|
||||||
subtask,
|
subtask,
|
||||||
@@ -132,6 +134,10 @@ export const judge = async (ctx) => {
|
|||||||
ctx.code = tpl[0] + ctx.code + tpl[1];
|
ctx.code = tpl[0] + ctx.code + tpl[1];
|
||||||
} else throw new CompileError('Language not supported by provided templates');
|
} 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.next({ status: STATUS.STATUS_COMPILING });
|
||||||
[ctx.execute, ctx.checker] = await Promise.all([
|
[ctx.execute, ctx.checker] = await Promise.all([
|
||||||
(async () => {
|
(async () => {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import Queue from 'p-queue';
|
import Queue from 'p-queue';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
import * as STATUS from '../status';
|
import * as STATUS from '../status';
|
||||||
import { parse } from '../testlib';
|
import { parse } from '../testlib';
|
||||||
import { findFileSync, parseFilename } from '../utils';
|
import { findFileSync, parseFilename } from '../utils';
|
||||||
@@ -8,6 +9,7 @@ import { run } from '../sandbox';
|
|||||||
import compile from '../compile';
|
import compile from '../compile';
|
||||||
import signals from '../signals';
|
import signals from '../signals';
|
||||||
import { getConfig } from '../config';
|
import { getConfig } from '../config';
|
||||||
|
import { SystemError } from '../error';
|
||||||
|
|
||||||
const testlibSrc = findFileSync('@hydrooj/hydrojudge/vendor/testlib/testlib.h');
|
const testlibSrc = findFileSync('@hydrooj/hydrojudge/vendor/testlib/testlib.h');
|
||||||
const Score = {
|
const Score = {
|
||||||
@@ -70,6 +72,7 @@ function judgeCase(c) {
|
|||||||
|
|
||||||
function judgeSubtask(subtask) {
|
function judgeSubtask(subtask) {
|
||||||
return async (ctx) => {
|
return async (ctx) => {
|
||||||
|
subtask.time *= ctx.time_limit_rate;
|
||||||
subtask.type = subtask.type || 'min';
|
subtask.type = subtask.type || 'min';
|
||||||
const ctxSubtask = {
|
const ctxSubtask = {
|
||||||
subtask,
|
subtask,
|
||||||
@@ -90,6 +93,10 @@ function judgeSubtask(subtask) {
|
|||||||
|
|
||||||
export const judge = async (ctx) => {
|
export const judge = async (ctx) => {
|
||||||
ctx.next({ status: STATUS.STATUS_COMPILING });
|
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([
|
[ctx.executeUser, ctx.executeInteractor] = await Promise.all([
|
||||||
(async () => {
|
(async () => {
|
||||||
const copyIn = {};
|
const copyIn = {};
|
||||||
|
|||||||
Reference in new issue
Block a user