mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
judge: config.template
This commit is contained in:
1 parent
b2fe14ffe7
commit
ab58505b9d
7 files changed
+85
-48
No files matched your search
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/hydrojudge",
|
"name": "@hydrooj/hydrojudge",
|
||||||
"bin": "bin/hydrojudge.js",
|
"bin": "bin/hydrojudge.js",
|
||||||
"version": "2.8.10",
|
"version": "2.8.11",
|
||||||
"main": "package.json",
|
"main": "package.json",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import Queue from 'p-queue';
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import fs from 'fs-extra';
|
import fs from 'fs-extra';
|
||||||
import * as STATUS from '../status';
|
import * as STATUS from '../status';
|
||||||
import { SystemError } from '../error';
|
import { CompileError, SystemError } from '../error';
|
||||||
import { parseFilename } from '../utils';
|
import { parseFilename } from '../utils';
|
||||||
import { run } from '../sandbox';
|
import { run } from '../sandbox';
|
||||||
import compile from '../compile';
|
import compile from '../compile';
|
||||||
@@ -18,6 +18,12 @@ const Score = {
|
|||||||
|
|
||||||
function judgeCase(c, sid) {
|
function judgeCase(c, sid) {
|
||||||
return async (ctx, ctxSubtask) => {
|
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 ((ctxSubtask.subtask.type === 'min' && !ctxSubtask.score)
|
||||||
|| (ctxSubtask.subtask.type === 'max' && ctxSubtask.score === ctxSubtask.subtask.score)
|
|| (ctxSubtask.subtask.type === 'max' && ctxSubtask.score === ctxSubtask.subtask.score)
|
||||||
|| (ctxSubtask.subtask.if && ctx.failed[sid])
|
|| (ctxSubtask.subtask.if && ctx.failed[sid])
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[data-marker-enabled]
|
[data-marker-enabled]
|
||||||
outline: 0
|
outline: 0
|
||||||
|
|
||||||
.marker
|
body > .marker
|
||||||
position: fixed
|
position: fixed
|
||||||
z-index: 100
|
z-index: 100
|
||||||
display: none
|
display: none
|
||||||
|
|||||||
@@ -15,6 +15,76 @@ const libSource = [
|
|||||||
const libUri = 'ts:filename/basic.d.ts';
|
const libUri = 'ts:filename/basic.d.ts';
|
||||||
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
monaco.languages.typescript.javascriptDefaults.addExtraLib(libSource, libUri);
|
||||||
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
monaco.editor.createModel(libSource, 'typescript', monaco.Uri.parse(libUri));
|
||||||
|
|
||||||
|
/** @type {Record<string, import('json-schema').JSONSchema7Definition>} */
|
||||||
|
const problemConfigSchemaDef = {
|
||||||
|
cases: { type: 'array', items: { $ref: '#/def/case' } },
|
||||||
|
case: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
input: { type: 'string' },
|
||||||
|
output: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['input'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
subtask: {
|
||||||
|
description: 'Subtask Info',
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
type: { enum: ['min', 'max', 'sum'] },
|
||||||
|
time: { $ref: '#/def/time' },
|
||||||
|
memory: { $ref: '#/def/memory' },
|
||||||
|
score: { $ref: '#/def/score', description: 'score' },
|
||||||
|
cases: { $ref: '#/def/cases' },
|
||||||
|
if: { type: 'array', items: { type: 'integer' } },
|
||||||
|
id: { type: 'integer' },
|
||||||
|
},
|
||||||
|
required: ['score'],
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
time: { type: 'string', pattern: '^([0-9]+(?:\\.[0-9]*)?)([mu]?)s?$' },
|
||||||
|
memory: { type: 'string', pattern: '^([0-9]+(?:\\.[0-9]*)?)([kmg])b?$' },
|
||||||
|
score: { type: 'integer', maximum: 100, minimum: 1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
/** @type {import('json-schema').JSONSchema7Definition} */
|
||||||
|
const problemConfigSchema = {
|
||||||
|
type: 'object',
|
||||||
|
def: problemConfigSchemaDef,
|
||||||
|
properties: {
|
||||||
|
type: { enum: ['default', 'interactive', 'submit_answer', 'subjective'] },
|
||||||
|
checker_type: { enum: ['default', 'lemon', 'syzoj', 'testlib', 'strict', 'qduoj'] },
|
||||||
|
checker: { type: 'string', pattern: '\\.' },
|
||||||
|
interactor: { type: 'string', pattern: '\\.' },
|
||||||
|
user_extra_files: { type: 'array', items: { type: 'string' } },
|
||||||
|
judge_extra_files: { type: 'array', items: { type: 'string' } },
|
||||||
|
cases: { $ref: '#/def/cases' },
|
||||||
|
subtasks: { type: 'array', items: { $ref: '#/def/subtask' } },
|
||||||
|
filename: { type: 'string' },
|
||||||
|
time: { $ref: '#/def/time' },
|
||||||
|
memory: { $ref: '#/def/memory' },
|
||||||
|
score: { $ref: '#/def/score' },
|
||||||
|
template: {
|
||||||
|
type: 'object',
|
||||||
|
patternProperties: {
|
||||||
|
'^.*$': {
|
||||||
|
type: 'array',
|
||||||
|
minLength: 2,
|
||||||
|
maxLength: 2,
|
||||||
|
items: { type: 'string' },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
additionalProperties: false,
|
||||||
|
},
|
||||||
|
outputs: {
|
||||||
|
type: 'array',
|
||||||
|
minLength: 1,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
additionalProperties: false,
|
||||||
|
};
|
||||||
|
|
||||||
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
||||||
validate: true,
|
validate: true,
|
||||||
enableSchemaRequest: true,
|
enableSchemaRequest: true,
|
||||||
@@ -25,50 +95,7 @@ monaco.languages.yaml.yamlDefaults.setDiagnosticsOptions({
|
|||||||
{
|
{
|
||||||
uri: 'https://hydro.js.org/schema/problemConfig.json',
|
uri: 'https://hydro.js.org/schema/problemConfig.json',
|
||||||
fileMatch: ['hydro://problem/file/config.yaml'],
|
fileMatch: ['hydro://problem/file/config.yaml'],
|
||||||
schema: {
|
schema: problemConfigSchema,
|
||||||
type: 'object',
|
|
||||||
def: {
|
|
||||||
cases: { type: 'array', items: { $ref: '#/def/case' } },
|
|
||||||
case: {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
input: { type: 'string' },
|
|
||||||
output: { type: 'string' },
|
|
||||||
},
|
|
||||||
required: ['input'],
|
|
||||||
},
|
|
||||||
subtask: {
|
|
||||||
description: 'Subtask Info',
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
type: { enum: ['min', 'max', 'sum'] },
|
|
||||||
time: { $ref: '#/def/time' },
|
|
||||||
memory: { $ref: '#/def/memory' },
|
|
||||||
score: { $ref: '#/def/score', description: 'score' },
|
|
||||||
cases: { $ref: '#/def/cases' },
|
|
||||||
if: { type: 'array', items: { type: 'integer' } },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
time: { type: 'string', pattern: '^([0-9]+(?:\\.[0-9]*)?)([mu]?)s?$' },
|
|
||||||
memory: { type: 'string', pattern: '^([0-9]+(?:\\.[0-9]*)?)([kmg])b?$' },
|
|
||||||
score: { type: 'integer', maximum: 100, minimum: 1 },
|
|
||||||
},
|
|
||||||
properties: {
|
|
||||||
type: { enum: ['default', 'interactive', 'submit_answer', 'subjective'] },
|
|
||||||
checker_type: { enum: ['default', 'lemon', 'syzoj', 'testlib', 'strict', 'qduoj'] },
|
|
||||||
checker: { type: 'string', pattern: '\\.' },
|
|
||||||
interactor: { type: 'string', pattern: '\\.' },
|
|
||||||
user_extra_files: { type: 'array', items: { type: 'string' } },
|
|
||||||
judge_extra_files: { type: 'array', items: { type: 'string' } },
|
|
||||||
cases: { $ref: '#/def/cases' },
|
|
||||||
subtasks: { type: 'array', items: { $ref: '#/def/subtask' } },
|
|
||||||
outputs: { type: 'array' },
|
|
||||||
filename: { type: 'string' },
|
|
||||||
time: { $ref: '#/def/time' },
|
|
||||||
memory: { $ref: '#/def/memory' },
|
|
||||||
score: { $ref: '#/def/score' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,3 +23,5 @@ import './components/notification';
|
|||||||
import './components/nprogress';
|
import './components/nprogress';
|
||||||
|
|
||||||
window.node_modules = { _, $ };
|
window.node_modules = { _, $ };
|
||||||
|
window.$ = $;
|
||||||
|
window.jQuery = $;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.11.31",
|
"version": "4.11.32",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
@@ -27,6 +27,7 @@
|
|||||||
"@blueprintjs/icons": "^3.26.1",
|
"@blueprintjs/icons": "^3.26.1",
|
||||||
"@blueprintjs/select": "^3.16.4",
|
"@blueprintjs/select": "^3.16.4",
|
||||||
"@hydrooj/utils": "^1.0.20",
|
"@hydrooj/utils": "^1.0.20",
|
||||||
|
"@types/json-schema": "^7.0.7",
|
||||||
"@types/katex": "^0.11.0",
|
"@types/katex": "^0.11.0",
|
||||||
"@undefined-moe/monaco-yaml": "^2.5.0",
|
"@undefined-moe/monaco-yaml": "^2.5.0",
|
||||||
"ansi_up": "^5.0.1",
|
"ansi_up": "^5.0.1",
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ const page = new NamedPage('problem_files', () => {
|
|||||||
</div>`,
|
</div>`,
|
||||||
width: `${window.innerWidth - 200}px`,
|
width: `${window.innerWidth - 200}px`,
|
||||||
height: `${window.innerHeight - 100}px`,
|
height: `${window.innerHeight - 100}px`,
|
||||||
|
cancelByEsc: false,
|
||||||
}).open();
|
}).open();
|
||||||
const language = {
|
const language = {
|
||||||
yaml: 'yaml',
|
yaml: 'yaml',
|
||||||
|
|||||||
Reference in new issue
Block a user