mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: fix testcase id generation
This commit is contained in:
1 parent
3edc425a52
commit
c4897b0aba
9 files changed
+33
-38
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.21.1",
|
||||
"version": "2.22.0",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -133,14 +133,11 @@ class JudgeTask {
|
||||
await judge[type].judge(this, startPromise);
|
||||
}
|
||||
|
||||
next(data: Partial<JudgeResultBody>, id?: number) {
|
||||
log.debug('Next: %d %o', id, data);
|
||||
next(data: Partial<JudgeResultBody>) {
|
||||
log.debug('Next: %d %o', data);
|
||||
data.key = 'next';
|
||||
data.rid = new ObjectID(this.rid);
|
||||
if (data.case) {
|
||||
data.case.id ||= id;
|
||||
data.case.message ||= '';
|
||||
}
|
||||
if (data.case) data.case.message ||= '';
|
||||
this.ws.send(JSON.stringify(data));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
) {
|
||||
ctx.next({
|
||||
case: {
|
||||
id: c.id,
|
||||
status: STATUS.STATUS_CANCELED,
|
||||
subtaskId: ctxSubtask.subtask.id,
|
||||
score: 0,
|
||||
@@ -35,7 +36,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
message: '',
|
||||
},
|
||||
addProgress: 100 / ctx.config.count,
|
||||
}, c.id);
|
||||
});
|
||||
return;
|
||||
}
|
||||
const { filename } = ctx.config;
|
||||
@@ -99,6 +100,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
ctx.total_memory_usage_kb = Math.max(ctx.total_memory_usage_kb, memory_usage_kb);
|
||||
ctx.next({
|
||||
case: {
|
||||
id: c.id,
|
||||
subtaskId: ctxSubtask.subtask.id,
|
||||
status,
|
||||
score,
|
||||
@@ -107,7 +109,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
message,
|
||||
},
|
||||
addProgress: 100 / ctx.config.count,
|
||||
}, c.id);
|
||||
});
|
||||
if ([STATUS.STATUS_WRONG_ANSWER, STATUS.STATUS_RUNTIME_ERROR].includes(status)) {
|
||||
const langConfig = ctx.getLang(ctx.lang);
|
||||
if (langConfig.analysis && !ctx.analysis) {
|
||||
|
||||
@@ -63,6 +63,7 @@ function judgeCase(c: NormalizedCase) {
|
||||
ctx.next({
|
||||
status: STATUS.STATUS_JUDGING,
|
||||
case: {
|
||||
id: c.id,
|
||||
subtaskId: ctxSubtask.subtask.id,
|
||||
status,
|
||||
score,
|
||||
@@ -70,8 +71,8 @@ function judgeCase(c: NormalizedCase) {
|
||||
memory: memory_usage_kb,
|
||||
message,
|
||||
},
|
||||
progress: Math.floor((c.id * 100) / ctx.config.count),
|
||||
}, c.id);
|
||||
addProgress: 100 / ctx.config.count,
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ export async function judge({
|
||||
score,
|
||||
message: 'Correct',
|
||||
},
|
||||
}, +caseId);
|
||||
});
|
||||
} else {
|
||||
totalStatus = STATUS.STATUS_WRONG_ANSWER;
|
||||
next({
|
||||
@@ -61,7 +61,7 @@ export async function judge({
|
||||
score: 0,
|
||||
message: 'Incorrect',
|
||||
},
|
||||
}, +caseId);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const stdAns = new Set(ansInfo[0] || []);
|
||||
@@ -79,7 +79,7 @@ export async function judge({
|
||||
score,
|
||||
message: 'Correct',
|
||||
},
|
||||
}, +caseId);
|
||||
});
|
||||
} else if (partialCorrect) {
|
||||
totalScore += Math.floor(score / 2);
|
||||
totalStatus = STATUS.STATUS_WRONG_ANSWER;
|
||||
@@ -91,7 +91,7 @@ export async function judge({
|
||||
score: Math.floor(score / 2),
|
||||
message: 'Partially Correct',
|
||||
},
|
||||
}, +caseId);
|
||||
});
|
||||
} else {
|
||||
totalStatus = STATUS.STATUS_WRONG_ANSWER;
|
||||
next({
|
||||
@@ -102,7 +102,7 @@ export async function judge({
|
||||
score: 0,
|
||||
message: 'Incorrect',
|
||||
},
|
||||
}, +caseId);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
if (ctxSubtask.status > STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
|
||||
ctx.next({
|
||||
case: {
|
||||
id: c.id,
|
||||
status,
|
||||
score: 0,
|
||||
time: 0,
|
||||
@@ -90,7 +91,7 @@ function judgeCase(c: NormalizedCase, sid: string) {
|
||||
message,
|
||||
},
|
||||
addProgress: 100 / ctx.config.count,
|
||||
}, c.id);
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -86,10 +86,10 @@ async function postInit() {
|
||||
}
|
||||
|
||||
function getNext(that) {
|
||||
return (data: Partial<JudgeResultBody>, id = 0) => {
|
||||
logger.debug('Next: %d %o', id, data);
|
||||
return (data: Partial<JudgeResultBody>) => {
|
||||
logger.debug('Next: %d %o', data);
|
||||
data.rid = new ObjectID(that.rid);
|
||||
if (data.case) data.case.id ||= id;
|
||||
if (data.case) data.case.message ||= '';
|
||||
_judge.next(data);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user