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",
"bin": "bin/hydrojudge.js",
"version": "2.8.13",
"version": "2.8.14",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
-3
View File
@@ -107,7 +107,6 @@ 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,8 +131,6 @@ function judgeSubtask(subtask, sid) {
export const judge = async (ctx) => {
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.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'),
copyIn: ctx.executeUser.copyIn,
time: ctxSubtask.subtask.time,
time: ctxSubtask.subtask.time * ctx.executeUser.time,
memory: ctxSubtask.subtask.memory,
}, {
execute: `${ctx.executeInteractor.execute.replace(/\$\{name\}/g, 'interactor')} /w/in /w/tout /w/out`,
copyIn: ctx.executeInteractor.copyIn,
time: ctxSubtask.subtask.time * 2,
time: ctxSubtask.subtask.time * 2 * ctx.executeInteractor.time,
memory: ctxSubtask.subtask.memory * 2,
copyOut: ['/w/tout?'],
},
@@ -37,7 +37,7 @@ function judgeCase(c) {
let status;
let score = 0;
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;
} else if (memory_usage_kb > ctxSubtask.subtask.memory * 1024) {
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
@@ -72,7 +72,6 @@ function judgeCase(c) {
function judgeSubtask(subtask) {
return async (ctx) => {
subtask.time *= ctx.time_limit_rate;
subtask.type = subtask.type || 'min';
const ctxSubtask = {
subtask,
@@ -93,7 +92,6 @@ function judgeSubtask(subtask) {
export const judge = async (ctx) => {
ctx.next({ status: STATUS.STATUS_COMPILING });
ctx.time_limit_rate = ctx.getLang(ctx.lang).time_limit_rate;
[ctx.executeUser, ctx.executeInteractor] = await Promise.all([
(() => {
const copyIn = {};
+3 -3
View File
@@ -68,7 +68,7 @@ export const judge = async (ctx) => {
stderr,
copyIn,
copyOut,
time: parseTimeMS(ctx.config.time || '1s'),
time: parseTimeMS(ctx.config.time || '1s') * ctx.execute.time,
memory: parseMemoryMB(ctx.config.memory || '128m'),
},
);
@@ -77,9 +77,9 @@ export const judge = async (ctx) => {
if (!fs.existsSync(stdout)) fs.writeFileSync(stdout, '');
const message: string[] = [];
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;
} 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;
}
} else if (code) {