From 085b6c9b4c01da3dcdca81e4d64b91570f7124e0 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 19 Feb 2025 04:38:48 +0800 Subject: [PATCH] judge: support kattis checker (#947) --- packages/hydrojudge/src/checkers.ts | 35 +++++++++++++++++++ .../components/monaco/schema/problemconfig.ts | 2 +- .../components/problemconfig/ProblemType.tsx | 2 +- 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/packages/hydrojudge/src/checkers.ts b/packages/hydrojudge/src/checkers.ts index 4c57ce4eb..cc29adde9 100644 --- a/packages/hydrojudge/src/checkers.ts +++ b/packages/hydrojudge/src/checkers.ts @@ -228,6 +228,41 @@ const checkers: Record = new Proxy({ } return parse(stderr, config.score); }, + + // https://www.kattis.com/problem-package-format/spec/2023-07-draft.html#output-validator + async kattis(config) { + const { files, code } = await runQueued(`${config.execute} input answer_file feedback_dir`, { + copyIn: { + input: config.input, + answer_file: config.output, + 'feedback_dir/placeholder': { content: '' }, + ...config.copyIn, + }, + stdin: config.user_stdout, + copyOut: [ + 'feedback_dir/score.txt?', + 'feedback_dir/judgemessage.txt?', + 'feedback_dir/teammessage.txt?', + 'feedback_dir/judgeerror.txt?', + ], + }); + + const status = code === 42 + ? STATUS.STATUS_ACCEPTED + : code === 43 + ? STATUS.STATUS_WRONG_ANSWER + : STATUS.STATUS_SYSTEM_ERROR; + + const score = status === STATUS.STATUS_ACCEPTED + ? config.score + : +files['feedback_dir/score.txt'] || 0; + + const message = status === STATUS.STATUS_SYSTEM_ERROR + ? files['feedback_dir/judgeerror.txt'] || `Checker exited with code ${code}` + : files['feedback_dir/teammessage.txt'] || files['feedback_dir/judgemessage.txt'] || ''; + + return { status, score, message }; + }, }, { get(self, key) { if (!self[key]) throw new FormatError('Unknown checker type {0}', [key]); diff --git a/packages/ui-default/components/monaco/schema/problemconfig.ts b/packages/ui-default/components/monaco/schema/problemconfig.ts index 663ef621b..d608ebf3a 100644 --- a/packages/ui-default/components/monaco/schema/problemconfig.ts +++ b/packages/ui-default/components/monaco/schema/problemconfig.ts @@ -70,7 +70,7 @@ const problemConfigSchema: JSONSchema7 = { subType: { type: 'string' }, langs: { type: 'array', items: { type: 'string' } }, target: { type: 'string' }, - checker_type: { enum: ['default', 'lemon', 'syzoj', 'hustoj', 'testlib', 'strict', 'qduoj'] }, + checker_type: { enum: ['default', 'lemon', 'syzoj', 'hustoj', 'testlib', 'strict', 'qduoj', 'kattis'] }, checker: { oneOf: [ { type: 'string', enum: testlibCheckers }, diff --git a/packages/ui-default/components/problemconfig/ProblemType.tsx b/packages/ui-default/components/problemconfig/ProblemType.tsx index 1113fa467..79f017abb 100644 --- a/packages/ui-default/components/problemconfig/ProblemType.tsx +++ b/packages/ui-default/components/problemconfig/ProblemType.tsx @@ -111,7 +111,7 @@ export default function ProblemType() { panel={(
- +