From 2393f105dc4fabc4f0964f0b508d05297ba1ea2b Mon Sep 17 00:00:00 2001 From: undefined Date: Tue, 3 Aug 2021 21:31:32 +0800 Subject: [PATCH] judge: better scoring method --- package.json | 10 +++++----- packages/center/package.json | 2 +- packages/hydrojudge/package.json | 4 ++-- packages/hydrojudge/src/judge/default.ts | 20 ++++++++++---------- packages/hydrooj/package.json | 4 ++-- packages/ui-default/package.json | 16 ++++++++-------- packages/utils/lib/cases.ts | 2 +- packages/utils/package.json | 4 ++-- packages/vjudge/package.json | 2 +- 9 files changed, 32 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 5bdf847a2..e49ba5285 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/packages/center/package.json b/packages/center/package.json index ca73a0bf2..2e3e2c7fc 100644 --- a/packages/center/package.json +++ b/packages/center/package.json @@ -12,7 +12,7 @@ }, "devDependencies": { "@types/js-yaml": "^4.0.2", - "@types/node": "^15.14.3" + "@types/node": "^15.14.5" }, "peerDependencies": { "hydrooj": "*" diff --git a/packages/hydrojudge/package.json b/packages/hydrojudge/package.json index 6dd822a4e..078394606 100644 --- a/packages/hydrojudge/package.json +++ b/packages/hydrojudge/package.json @@ -1,7 +1,7 @@ { "name": "@hydrooj/hydrojudge", "bin": "bin/hydrojudge.js", - "version": "2.9.5", + "version": "2.9.6", "main": "package.json", "author": "undefined ", "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" }, diff --git a/packages/hydrojudge/src/judge/default.ts b/packages/hydrojudge/src/judge/default.ts index 590103308..b603dc44e 100644 --- a/packages/hydrojudge/src/judge/default.ts +++ b/packages/hydrojudge/src/judge/default.ts @@ -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 = {}; diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 07e31c971..7846546ce 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -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", diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index a13587bd9..72615f333 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -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", diff --git a/packages/utils/lib/cases.ts b/packages/utils/lib/cases.ts index 68e83434f..54b6be82e 100644 --- a/packages/utils/lib/cases.ts +++ b/packages/utils/lib/cases.ts @@ -60,7 +60,7 @@ export default async function readYamlCases(cfg: Record = {}, 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', diff --git a/packages/utils/package.json b/packages/utils/package.json index f2e8e6fa4..c3a864adc 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -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" } } diff --git a/packages/vjudge/package.json b/packages/vjudge/package.json index 713a69d49..68d8c5855 100644 --- a/packages/vjudge/package.json +++ b/packages/vjudge/package.json @@ -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" },