mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +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 totalStatus = 0;
|
||||
const subtasks = {};
|
||||
if (!Object.keys(config.answers).length) throw new FormatError('Invalid standard answer.');
|
||||
for (const key in config.answers) {
|
||||
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);
|
||||
totalScore += score;
|
||||
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({
|
||||
status: totalStatus,
|
||||
case: {
|
||||
@@ -59,9 +65,10 @@ export async function judge({
|
||||
const fullScore = (+ansInfo[1]) || 0;
|
||||
const stdAns = ansInfo[0];
|
||||
if (stdAns instanceof Array) {
|
||||
const stdSet = new Set(stdAns);
|
||||
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');
|
||||
else if (ans.size && Set.isSuperset(ans, stdAns)) report(STATUS.STATUS_WRONG_ANSWER, Math.floor(fullScore / 2), 'Partially Correct');
|
||||
if (stdAns.length === ans.size && Set.isSuperset(stdSet, ans)) report(STATUS.STATUS_ACCEPTED, fullScore, '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 if (stdAns.toString() === usrAns) report(STATUS.STATUS_ACCEPTED, fullScore, 'Correct');
|
||||
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');
|
||||
}
|
||||
end({
|
||||
status: totalStatus, score: totalScore, time: 0, memory: 0,
|
||||
status: totalStatus, score: totalScore, time: 0, memory: 0, subtasks,
|
||||
});
|
||||
return null;
|
||||
}
|
||||
@@ -71,7 +71,7 @@
|
||||
<span class="record-status--text {{ model.builtin.STATUS_CODES[rcdoc['status']] }}">
|
||||
{{ model.builtin.STATUS_TEXTS[rcdoc['status']] }}
|
||||
</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] }}">
|
||||
{{ (rdoc.subtasks[subtaskId]['score'] if _key != 'id' else rcdoc.score)|default(0) }}
|
||||
</span>
|
||||
|
||||
Reference in new issue
Block a user