mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: fix pc & add objective subtask score (#534)
This commit is contained in:
1 parent
2679703840
commit
366b01aa75
2 files changed
+11
-4
No files matched your search
@@ -29,6 +29,7 @@ export async function judge({
|
|||||||
}
|
}
|
||||||
let totalScore = 0;
|
let totalScore = 0;
|
||||||
let totalStatus = 0;
|
let totalStatus = 0;
|
||||||
|
const subtasks = {};
|
||||||
if (!Object.keys(config.answers).length) throw new FormatError('Invalid standard answer.');
|
if (!Object.keys(config.answers).length) throw new FormatError('Invalid standard answer.');
|
||||||
for (const key in config.answers) {
|
for (const key in config.answers) {
|
||||||
const ansInfo = config.answers[key] as [string | string[], number] | Record<string, number>;
|
const ansInfo = config.answers[key] as [string | string[], number] | Record<string, number>;
|
||||||
@@ -37,6 +38,11 @@ export async function judge({
|
|||||||
const [subtaskId, caseId] = key.split('-').map(Number);
|
const [subtaskId, caseId] = key.split('-').map(Number);
|
||||||
totalScore += score;
|
totalScore += score;
|
||||||
totalStatus = Math.max(totalStatus, status);
|
totalStatus = Math.max(totalStatus, status);
|
||||||
|
subtasks[subtaskId] ||= { score, status };
|
||||||
|
if (subtasks[subtaskId].status && caseId) {
|
||||||
|
subtasks[subtaskId].score += score;
|
||||||
|
subtasks[subtaskId].status = Math.max(subtasks[subtaskId].status, status);
|
||||||
|
}
|
||||||
next({
|
next({
|
||||||
status: totalStatus,
|
status: totalStatus,
|
||||||
case: {
|
case: {
|
||||||
@@ -59,9 +65,10 @@ export async function judge({
|
|||||||
const fullScore = (+ansInfo[1]) || 0;
|
const fullScore = (+ansInfo[1]) || 0;
|
||||||
const stdAns = ansInfo[0];
|
const stdAns = ansInfo[0];
|
||||||
if (stdAns instanceof Array) {
|
if (stdAns instanceof Array) {
|
||||||
|
const stdSet = new Set(stdAns);
|
||||||
const ans = new Set(answers[key] instanceof Array ? answers[key] : [answers[key]]);
|
const ans = new Set(answers[key] instanceof Array ? answers[key] : [answers[key]]);
|
||||||
if (stdAns.length === ans.size && Set.isSuperset(ans, stdAns)) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct');
|
if (stdAns.length === ans.size && Set.isSuperset(stdSet, ans)) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct');
|
||||||
else if (ans.size && Set.isSuperset(ans, stdAns)) report(STATUS.STATUS_WRONG_ANSWER, Math.floor(fullScore / 2), 'Partially Correct');
|
else if (ans.size && Set.isSuperset(stdSet, ans)) report(STATUS.STATUS_WRONG_ANSWER, Math.floor(fullScore / 2), 'Partially Correct');
|
||||||
else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect');
|
else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect');
|
||||||
} else if (stdAns.toString() === usrAns) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct');
|
} else if (stdAns.toString() === usrAns) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct');
|
||||||
else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect');
|
else report(STATUS.STATUS_WRONG_ANSWER, 0, 'Incorrect');
|
||||||
@@ -69,7 +76,7 @@ export async function judge({
|
|||||||
else report(STATUS.STATUS_ACCEPTED, +ansInfo[usrAns] || 0, 'Correct');
|
else report(STATUS.STATUS_ACCEPTED, +ansInfo[usrAns] || 0, 'Correct');
|
||||||
}
|
}
|
||||||
end({
|
end({
|
||||||
status: totalStatus, score: totalScore, time: 0, memory: 0,
|
status: totalStatus, score: totalScore, time: 0, memory: 0, subtasks,
|
||||||
});
|
});
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -71,7 +71,7 @@
|
|||||||
<span class="record-status--text {{ model.builtin.STATUS_CODES[rcdoc['status']] }}">
|
<span class="record-status--text {{ model.builtin.STATUS_CODES[rcdoc['status']] }}">
|
||||||
{{ model.builtin.STATUS_TEXTS[rcdoc['status']] }}
|
{{ model.builtin.STATUS_TEXTS[rcdoc['status']] }}
|
||||||
</span>
|
</span>
|
||||||
{% if (_key != 'id' and rcdocs.length == 1) or (_key == 'id' and rdoc.subtasks[rcdoc.subtaskId].type == 'sum') %}
|
{% if (rdoc.subtask && _key != 'id' and rcdocs.length == 1 ) or (_key == 'id' and rdoc.subtasks[rcdoc.subtaskId].type == 'sum') %}
|
||||||
<span class="float-right record-status--text {{ model.builtin.STATUS_CODES[rdoc.subtasks[subtaskId]['status'] if _key != 'id' else rcdoc.status] }}">
|
<span class="float-right record-status--text {{ model.builtin.STATUS_CODES[rdoc.subtasks[subtaskId]['status'] if _key != 'id' else rcdoc.status] }}">
|
||||||
{{ (rdoc.subtasks[subtaskId]['score'] if _key != 'id' else rcdoc.score)|default(0) }}
|
{{ (rdoc.subtasks[subtaskId]['score'] if _key != 'id' else rcdoc.score)|default(0) }}
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in new issue
Block a user