judge: also enable time_limit_rate for pretest

This commit is contained in:
undefined committed 2021-07-04 10:46:35 +08:00
1 parent 17806f5bf3
commit 18450dafea
4 files changed
+7 -12

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
{ {
"name": "@hydrooj/hydrojudge", "name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js", "bin": "bin/hydrojudge.js",
"version": "2.8.13", "version": "2.8.14",
"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",
-3
View File
@@ -107,7 +107,6 @@ 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,8 +131,6 @@ function judgeSubtask(subtask, sid) {
export const judge = async (ctx) => { export const judge = async (ctx) => {
if (!ctx.config.subtasks.length) throw new SystemError('Problem data not found.'); if (!ctx.config.subtasks.length) throw new SystemError('Problem data not found.');
const info = ctx.getLang(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([
(() => { (() => {
+3 -5
View File
@@ -23,12 +23,12 @@ function judgeCase(c) {
{ {
execute: ctx.executeUser.execute.replace(/\$\{name\}/g, 'code'), execute: ctx.executeUser.execute.replace(/\$\{name\}/g, 'code'),
copyIn: ctx.executeUser.copyIn, copyIn: ctx.executeUser.copyIn,
time: ctxSubtask.subtask.time, time: ctxSubtask.subtask.time * ctx.executeUser.time,
memory: ctxSubtask.subtask.memory, memory: ctxSubtask.subtask.memory,
}, { }, {
execute: `${ctx.executeInteractor.execute.replace(/\$\{name\}/g, 'interactor')} /w/in /w/tout /w/out`, execute: `${ctx.executeInteractor.execute.replace(/\$\{name\}/g, 'interactor')} /w/in /w/tout /w/out`,
copyIn: ctx.executeInteractor.copyIn, copyIn: ctx.executeInteractor.copyIn,
time: ctxSubtask.subtask.time * 2, time: ctxSubtask.subtask.time * 2 * ctx.executeInteractor.time,
memory: ctxSubtask.subtask.memory * 2, memory: ctxSubtask.subtask.memory * 2,
copyOut: ['/w/tout?'], copyOut: ['/w/tout?'],
}, },
@@ -37,7 +37,7 @@ function judgeCase(c) {
let status; let status;
let score = 0; let score = 0;
let message: any = ''; let message: any = '';
if (time_usage_ms > ctxSubtask.subtask.time) { if (time_usage_ms > ctxSubtask.subtask.time * ctx.executeUser.time) {
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED; status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
} else if (memory_usage_kb > ctxSubtask.subtask.memory * 1024) { } else if (memory_usage_kb > ctxSubtask.subtask.memory * 1024) {
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED; status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
@@ -72,7 +72,6 @@ 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,
@@ -93,7 +92,6 @@ 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 });
ctx.time_limit_rate = ctx.getLang(ctx.lang).time_limit_rate;
[ctx.executeUser, ctx.executeInteractor] = await Promise.all([ [ctx.executeUser, ctx.executeInteractor] = await Promise.all([
(() => { (() => {
const copyIn = {}; const copyIn = {};
+3 -3
View File
@@ -68,7 +68,7 @@ export const judge = async (ctx) => {
stderr, stderr,
copyIn, copyIn,
copyOut, copyOut,
time: parseTimeMS(ctx.config.time || '1s'), time: parseTimeMS(ctx.config.time || '1s') * ctx.execute.time,
memory: parseMemoryMB(ctx.config.memory || '128m'), memory: parseMemoryMB(ctx.config.memory || '128m'),
}, },
); );
@@ -77,9 +77,9 @@ export const judge = async (ctx) => {
if (!fs.existsSync(stdout)) fs.writeFileSync(stdout, ''); if (!fs.existsSync(stdout)) fs.writeFileSync(stdout, '');
const message: string[] = []; const message: string[] = [];
if (status === STATUS.STATUS_ACCEPTED) { if (status === STATUS.STATUS_ACCEPTED) {
if (time_usage_ms > ctx.config.time) { if (time_usage_ms > parseTimeMS(ctx.config.time || '1s') * ctx.execute.time) {
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED; status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
} else if (memory_usage_kb > ctx.config.memory * 1024) { } else if (memory_usage_kb > parseMemoryMB(ctx.config.memory || '128m') * 1024) {
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED; status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
} }
} else if (code) { } else if (code) {