judge: better scoring method

This commit is contained in:
undefined committed 2021-08-03 21:31:32 +08:00
1 parent b0e7512d7a
commit 2393f105dc
9 files changed
+32 -32

No files matched your search

+5 -5
View File
@@ -28,14 +28,14 @@
"license": "AGPL-3.0-only",
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/node": "^15.14.3",
"@types/node": "^15.14.5",
"@types/semver": "^7.3.8",
"@typescript-eslint/eslint-plugin": "^4.28.4",
"@typescript-eslint/parser": "^4.28.4",
"@typescript-eslint/eslint-plugin": "^4.29.0",
"@typescript-eslint/parser": "^4.29.0",
"cac": "^6.7.3",
"cross-env": "^7.0.3",
"cross-spawn": "^7.0.3",
"eslint": "^7.31.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-typescript": "^12.3.1",
"eslint-import-resolver-typescript": "^2.4.0",
"eslint-plugin-import": "^2.23.4",
@@ -46,7 +46,7 @@
"nmls": "^3.0.1",
"ora": "^5.4.1",
"semver": "^7.3.5",
"typedoc": "^0.21.4",
"typedoc": "^0.21.5",
"typescript": "4.2.4"
}
}
+1 -1
View File
@@ -12,7 +12,7 @@
},
"devDependencies": {
"@types/js-yaml": "^4.0.2",
"@types/node": "^15.14.3"
"@types/node": "^15.14.5"
},
"peerDependencies": {
"hydrooj": "*"
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "@hydrooj/hydrojudge",
"bin": "bin/hydrojudge.js",
"version": "2.9.5",
"version": "2.9.6",
"main": "package.json",
"author": "undefined <i@undefined.moe>",
"repository": "https://github.com/hydro-dev/Hydro.git",
@@ -23,7 +23,7 @@
"devDependencies": {
"@types/fs-extra": "^9.0.12",
"@types/js-yaml": "^4.0.2",
"@types/lodash": "^4.14.171",
"@types/lodash": "^4.14.172",
"@types/shell-quote": "^1.7.1",
"@types/ws": "^7.4.7"
},
+10 -10
View File
@@ -18,16 +18,10 @@ const Score = {
function judgeCase(c, sid: string) {
return async (ctx, ctxSubtask) => {
if (ctx.config.template) {
if (ctx.config.template[ctx.lang]) {
const tpl = ctx.config.template[ctx.lang];
ctx.code = tpl[0] + ctx.code + tpl[1];
} else throw new CompileError('Language not supported by provided templates');
}
if ((ctxSubtask.subtask.type === 'min' && !ctxSubtask.score)
if (ctx.failed[sid] || ctx.errored
|| (ctxSubtask.subtask.type === 'max' && ctxSubtask.score === ctxSubtask.subtask.score)
|| (ctxSubtask.subtask.if && ctx.failed[sid])
|| ctx.errored) {
|| ((ctxSubtask.subtask.if || []).filter((i: string) => ctx.failed[i]).length)
) {
ctx.next({
case: {
status: STATUS.STATUS_CANCELED,
@@ -94,6 +88,7 @@ function judgeCase(c, sid: string) {
]).catch(() => { /* Ignore file doesn't exist */ });
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;
ctx.total_time_usage_ms += time_usage_ms;
ctx.total_memory_usage_kb = Math.max(ctx.total_memory_usage_kb, memory_usage_kb);
ctx.next({
@@ -128,7 +123,6 @@ function judgeSubtask(subtask, sid: string) {
throw e;
});
ctx.total_status = Math.max(ctx.total_status, ctxSubtask.status);
if (ctx.total_status !== STATUS.STATUS_ACCEPTED) ctx.failed[sid] = true;
return ctxSubtask.score;
};
}
@@ -136,6 +130,12 @@ function judgeSubtask(subtask, sid: string) {
export const judge = async (ctx) => {
if (!ctx.config.subtasks.length) throw new SystemError('Problem data not found.');
ctx.next({ status: STATUS.STATUS_COMPILING });
if (ctx.config.template) {
if (ctx.config.template[ctx.lang]) {
const tpl = ctx.config.template[ctx.lang];
ctx.code = tpl[0] + ctx.code + tpl[1];
} else throw new CompileError('Language not supported by provided templates');
}
[ctx.execute, ctx.checker] = await Promise.all([
(() => {
const copyIn = {};
+2 -2
View File
@@ -47,9 +47,9 @@
"@types/koa-compress": "^4.0.3",
"@types/koa-router": "^7.4.4",
"@types/koa-static-cache": "^5.1.1",
"@types/lodash": "^4.14.171",
"@types/lodash": "^4.14.172",
"@types/lru-cache": "^5.1.1",
"@types/minio": "^7.0.8",
"@types/minio": "^7.0.9",
"@types/mongodb": "^3.6.20",
"@types/nodemailer": "^6.4.4",
"@types/serialize-javascript": "^5.0.1",
+8 -8
View File
@@ -9,7 +9,7 @@
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/core": "^7.14.8",
"@babel/eslint-parser": "7.14.7",
"@babel/eslint-parser": "7.14.9",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-export-namespace-from": "^7.14.5",
"@babel/plugin-proposal-function-sent": "^7.14.5",
@@ -19,11 +19,11 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/preset-env": "^7.14.8",
"@babel/preset-env": "^7.14.9",
"@babel/preset-react": "^7.14.5",
"@babel/register": "^7.14.5",
"@babel/runtime-corejs3": "^7.14.8",
"@blockly/block-extension-tooltip": "^1.0.14",
"@babel/runtime-corejs3": "^7.14.9",
"@blockly/block-extension-tooltip": "^1.0.15",
"@blueprintjs/core": "^3.47.0",
"@blueprintjs/icons": "^3.27.0",
"@blueprintjs/select": "^3.16.6",
@@ -37,7 +37,7 @@
"babel-plugin-lodash": "^3.3.4",
"babel-plugin-prismjs": "^2.1.0",
"blockly": "^6.20210701.0",
"chalk": "^4.1.1",
"chalk": "^4.1.2",
"classnames": "^2.3.1",
"clipboard": "^2.0.8",
"copy-webpack-plugin": "^6.4.1",
@@ -46,7 +46,7 @@
"diff-dom": "^4.2.2",
"echarts": "^5.1.2",
"emojify.js": "^1.1.0",
"eslint": "^7.31.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-import-resolver-webpack": "^0.13.1",
"eslint-plugin-babel": "^5.3.1",
@@ -113,13 +113,13 @@
"webpackbar": "^5.0.0-3"
},
"dependencies": {
"esbuild": "^0.12.16",
"esbuild": "^0.12.17",
"esbuild-loader": "^2.13.1",
"js-yaml": "^4.1.0",
"jsesc": "^3.0.2",
"katex": "^0.13.13",
"lodash": "^4.17.21",
"markdown-it": "^12.1.0",
"markdown-it": "^12.2.0",
"markdown-it-anchor": "^7.1.0",
"markdown-it-footnote": "^3.0.3",
"markdown-it-imsize": "^2.0.1",
+1 -1
View File
@@ -60,7 +60,7 @@ export default async function readYamlCases(cfg: Record<string, any> = {}, check
});
}
config.subtasks.push({
score: parseInt(subtask.score, 10) || 100,
score: Number.isSafeInteger(+subtask.score) ? +subtask.score : 100,
if: subtask.if || [],
cases,
type: subtask.type || 'min',
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/utils",
"version": "1.1.1",
"version": "1.1.2",
"description": "hydrooj utils",
"main": "package.json",
"repository": "https://github.com/hydro-dev/Hydro.git",
@@ -16,7 +16,7 @@
},
"devDependencies": {
"@types/fs-extra": "^9.0.12",
"@types/node": "^15.14.3",
"@types/node": "^15.14.5",
"moment-timezone": "^0.5.33"
}
}
+1 -1
View File
@@ -9,7 +9,7 @@
"preferUnplugged": true,
"dependencies": {
"@hydrooj/utils": "workspace:*",
"jsdom": "^16.6.0",
"jsdom": "^16.7.0",
"superagent": "^6.1.0",
"superagent-proxy": "^2.1.0"
},