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
+27
-32
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);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -279,10 +279,7 @@ export function normalizeSubtasks(
|
||||
Math.max(100 - Math.sum(subtasks.map((i) => i.score || 0)), 0),
|
||||
subtasks.filter((i) => !i.score).length,
|
||||
);
|
||||
let id = 0;
|
||||
let count = 0;
|
||||
return subtasks.map((s) => {
|
||||
id++;
|
||||
return subtasks.map((s, id) => {
|
||||
s.cases.sort((a, b) => (a.id - b.id));
|
||||
const score = s.score || subtaskScore.next().value as number;
|
||||
const caseScore = getScore(
|
||||
@@ -290,25 +287,22 @@ export function normalizeSubtasks(
|
||||
s.cases.filter((i) => !i.score).length,
|
||||
);
|
||||
return {
|
||||
id,
|
||||
id: id + 1,
|
||||
type: 'min',
|
||||
if: [],
|
||||
...s,
|
||||
score,
|
||||
time: parseTimeMS(s.time || time, !ignoreParseError),
|
||||
memory: parseMemoryMB(s.memory || memory, !ignoreParseError),
|
||||
cases: s.cases.map((c) => {
|
||||
count++;
|
||||
return {
|
||||
id: count,
|
||||
cases: s.cases.map((c, index) => ({
|
||||
id: index + 1,
|
||||
...c,
|
||||
score: c.score || (s.type === 'sum' ? caseScore.next().value as number : score),
|
||||
time: parseTimeMS(c.time || s.time || time, !ignoreParseError),
|
||||
memory: parseMemoryMB(c.memory || s.memory || memory, !ignoreParseError),
|
||||
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : '/dev/null',
|
||||
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : '/dev/null',
|
||||
};
|
||||
}) as NormalizedCase[],
|
||||
})) as NormalizedCase[],
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@hydrooj/utils",
|
||||
"version": "1.3.1",
|
||||
"version": "1.3.2",
|
||||
"description": "hydrooj utils",
|
||||
"main": "package.json",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
Reference in new issue
Block a user