mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
judge: update auto parse
This commit is contained in:
1 parent
37e71cf967
commit
2db1570d1b
2 files changed
+41
-57
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.5.6",
|
"version": "2.5.7",
|
||||||
"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",
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import { getConfig } from './config';
|
|||||||
|
|
||||||
interface Re0 {
|
interface Re0 {
|
||||||
reg: RegExp,
|
reg: RegExp,
|
||||||
output: (a: RegExpExecArray) => string,
|
output: ((a: RegExpExecArray) => string)[],
|
||||||
id: (a: RegExpExecArray) => number,
|
id: (a: RegExpExecArray) => number,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,52 +20,30 @@ interface Re1 extends Re0 {
|
|||||||
|
|
||||||
const RE0: Re0[] = [
|
const RE0: Re0[] = [
|
||||||
{
|
{
|
||||||
reg: /^([^\d]*)([0-9]+).in$/,
|
reg: /^([^\d]*)(\d+).(in|txt)$/,
|
||||||
output: (a) => `${a[1] + a[2]}.out`,
|
output: [
|
||||||
id: (a) => parseInt(a[2], 10),
|
(a) => `${a[1] + a[2]}.out`,
|
||||||
|
(a) => `${a[1] + a[2]}.ans`,
|
||||||
|
(a) => `${a[1] + a[2]}.out`.replace(/input/g, 'output'),
|
||||||
|
(a) => `${a[1] + a[2]}.txt`.replace(/input/g, 'output'),
|
||||||
|
],
|
||||||
|
id: (a) => +a[2],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
reg: /^([^\d]*)([0-9]+).in$/,
|
reg: /^([^\d]*)\.in(\d+)$/,
|
||||||
output: (a) => `${a[1] + a[2]}.ans`,
|
output: [
|
||||||
id: (a) => parseInt(a[2], 10),
|
(a) => `${a[1]}.ou${a[2]}`,
|
||||||
},
|
(a) => `${a[1]}.ou${a[2]}`.replace(/input/g, 'output'),
|
||||||
{
|
],
|
||||||
reg: /^([^\d]*)\.in([0-9]+)$/,
|
id: (a) => +a[2],
|
||||||
output: (a) => `${a[1]}.ou${a[2]}`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
reg: /^(input)([0-9]+).txt$/,
|
|
||||||
output: (a) => `output${a[2]}.txt`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
reg: /^input\/([^\d]*)([0-9]+).in$/,
|
|
||||||
output: (a) => `output/${a[1] + a[2]}.out`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
reg: /^input\/([^\d]*)([0-9]+).in$/,
|
|
||||||
output: (a) => `output/${a[1] + a[2]}.ans`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
reg: /^input\/([^\d]*)\.in([0-9]+)$/,
|
|
||||||
output: (a) => `output/${a[1]}.ou${a[2]}`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
reg: /^input\/(input)([0-9]+).txt$/,
|
|
||||||
output: (a) => `output/output${a[2]}.txt`,
|
|
||||||
id: (a) => parseInt(a[2], 10),
|
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
const RE1: Re1[] = [
|
const RE1: Re1[] = [
|
||||||
{
|
{
|
||||||
reg: /^([a-z+_\-A-Z]*)([0-9]+)-([0-9]+).in$/,
|
reg: /^([^\d]*)([0-9]+)-([0-9]+).in$/,
|
||||||
output: (a) => `${a[1] + a[2]}-${a[3]}.out`,
|
output: [(a) => `${a[1] + a[2]}-${a[3]}.out`],
|
||||||
subtask: (a) => parseInt(a[2], 10),
|
subtask: (a) => +a[2],
|
||||||
id: (a) => parseInt(a[3], 10),
|
id: (a) => +a[3],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -75,10 +53,13 @@ async function read0(folder: string, files: string[], checkFile, cfg) {
|
|||||||
for (const REG of RE0) {
|
for (const REG of RE0) {
|
||||||
if (REG.reg.test(file)) {
|
if (REG.reg.test(file)) {
|
||||||
const data = REG.reg.exec(file);
|
const data = REG.reg.exec(file);
|
||||||
const c = { input: file, output: REG.output(data), id: REG.id(data) };
|
const c = { input: file, output: '', id: REG.id(data) };
|
||||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
for (const func of REG.output) {
|
||||||
cases.push(c);
|
c.output = func(data);
|
||||||
break;
|
if (fs.existsSync(path.resolve(folder, c.output))) {
|
||||||
|
cases.push(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -130,17 +111,20 @@ async function read1(folder: string, files: string[], checkFile, cfg) {
|
|||||||
for (const REG of RE1) {
|
for (const REG of RE1) {
|
||||||
if (REG.reg.test(file)) {
|
if (REG.reg.test(file)) {
|
||||||
const data = REG.reg.exec(file);
|
const data = REG.reg.exec(file);
|
||||||
const c = { input: file, output: REG.output(data), id: REG.id(data) };
|
const c = { input: file, output: '', id: REG.id(data) };
|
||||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
for (const func of REG.output) {
|
||||||
if (!subtask[REG.subtask(data)]) {
|
c.output = func(data);
|
||||||
subtask[REG.subtask(data)] = [{
|
if (fs.existsSync(path.resolve(folder, c.output))) {
|
||||||
time: parseTimeMS(cfg.time || '1s'),
|
if (!subtask[REG.subtask(data)]) {
|
||||||
memory: parseMemoryMB(cfg.memory || '256m'),
|
subtask[REG.subtask(data)] = [{
|
||||||
type: 'min',
|
time: parseTimeMS(cfg.time || '1s'),
|
||||||
cases: [c],
|
memory: parseMemoryMB(cfg.memory || '256m'),
|
||||||
}];
|
type: 'min',
|
||||||
} else subtask[REG.subtask(data)].cases.push(c);
|
cases: [c],
|
||||||
break;
|
}];
|
||||||
|
} else subtask[REG.subtask(data)].cases.push(c);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user