mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: allow rerun when tle
This commit is contained in:
1 parent
27219776bf
commit
8965a87910
4 files changed
+16
-3
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.10.10",
|
||||
"version": "2.10.11",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -52,6 +52,11 @@ rate:
|
||||
name: rate
|
||||
desc: (?)
|
||||
default: 1
|
||||
rerun:
|
||||
type: number
|
||||
name: rerun
|
||||
desc: Re-Run testcase if time-limit-exceeded (max per submission)
|
||||
default: 0
|
||||
disable:
|
||||
type: boolean
|
||||
name: disable
|
||||
|
||||
@@ -20,6 +20,7 @@ let config = {
|
||||
testcases_max: 100,
|
||||
total_time_limit: 60,
|
||||
parallelism: 2,
|
||||
rerun: 0,
|
||||
rate: 1,
|
||||
config: null,
|
||||
langs: null,
|
||||
|
||||
@@ -17,7 +17,7 @@ const Score = {
|
||||
};
|
||||
|
||||
function judgeCase(c, sid: string) {
|
||||
return async (ctx, ctxSubtask) => {
|
||||
return async (ctx, ctxSubtask, runner?: Function) => {
|
||||
if (ctx.errored || (ctx.failed[sid] && ctxSubtask.subtask.type === 'min')
|
||||
|| (ctxSubtask.subtask.type === 'max' && ctxSubtask.score === ctxSubtask.subtask.score)
|
||||
|| ((ctxSubtask.subtask.if || []).filter((i: string) => ctx.failed[i]).length)
|
||||
@@ -86,6 +86,11 @@ function judgeCase(c, sid: string) {
|
||||
fs.remove(stdout),
|
||||
fs.remove(stderr),
|
||||
]).catch(() => { /* Ignore file doesn't exist */ });
|
||||
if (runner && ctx.rerun && status === STATUS.STATUS_TIME_LIMIT_EXCEEDED) {
|
||||
ctx.rerun--;
|
||||
await runner(ctx, ctxSubtask);
|
||||
return;
|
||||
}
|
||||
ctxSubtask.score = Score[ctxSubtask.subtask.type](ctxSubtask.score, score);
|
||||
ctxSubtask.status = Math.max(ctxSubtask.status, status);
|
||||
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
||||
@@ -116,7 +121,8 @@ function judgeSubtask(subtask, sid: string) {
|
||||
};
|
||||
const cases = [];
|
||||
for (const cid in subtask.cases) {
|
||||
cases.push(ctx.queue.add(() => judgeCase(subtask.cases[cid], sid)(ctx, ctxSubtask)));
|
||||
const runner = judgeCase(subtask.cases[cid], sid);
|
||||
cases.push(ctx.queue.add(() => runner(ctx, ctxSubtask, runner)));
|
||||
}
|
||||
await Promise.all(cases).catch((e) => {
|
||||
ctx.errored = true;
|
||||
@@ -167,6 +173,7 @@ export const judge = async (ctx) => {
|
||||
ctx.total_score = 0;
|
||||
ctx.total_memory_usage_kb = 0;
|
||||
ctx.total_time_usage_ms = 0;
|
||||
ctx.rerun = getConfig('rerun') || 0;
|
||||
ctx.queue = new Queue({ concurrency: getConfig('parallelism') });
|
||||
ctx.failed = {};
|
||||
for (const sid in ctx.config.subtasks) tasks.push(judgeSubtask(ctx.config.subtasks[sid], sid)(ctx));
|
||||
|
||||
Reference in new issue
Block a user