mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
judge: 修复 time&mem limit 在自动模式不生效的问题
This commit is contained in:
1 parent
8e90f24d01
commit
d6349a70cf
4 files changed
+20
-20
No files matched your search
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@hydrooj/hydrojudge",
|
||||
"bin": "bin/hydrojudge.js",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"main": "package.json",
|
||||
"author": "undefined <i@undefined.moe>",
|
||||
"repository": "https://github.com/hydro-dev/Hydro.git",
|
||||
|
||||
@@ -67,7 +67,7 @@ const RE1: Re1[] = [
|
||||
},
|
||||
];
|
||||
|
||||
async function read0(folder: string, files: string[], checkFile) {
|
||||
async function read0(folder: string, files: string[], checkFile, cfg) {
|
||||
const cases = [];
|
||||
for (const file of files) {
|
||||
for (const REG of RE0) {
|
||||
@@ -86,8 +86,8 @@ async function read0(folder: string, files: string[], checkFile) {
|
||||
const config = {
|
||||
count: 0,
|
||||
subtasks: [{
|
||||
time_limit_ms: 1000,
|
||||
memory_limit_mb: 512,
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'sum',
|
||||
cases: [],
|
||||
score: Math.floor(100 / cases.length),
|
||||
@@ -103,8 +103,8 @@ async function read0(folder: string, files: string[], checkFile) {
|
||||
}
|
||||
if (extra < cases.length) {
|
||||
config.subtasks.push({
|
||||
time_limit_ms: 1000,
|
||||
memory_limit_mb: 512,
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'sum',
|
||||
cases: [],
|
||||
score: Math.floor(100 / cases.length) + 1,
|
||||
@@ -121,7 +121,7 @@ async function read0(folder: string, files: string[], checkFile) {
|
||||
return config;
|
||||
}
|
||||
|
||||
async function read1(folder: string, files: string[], checkFile) {
|
||||
async function read1(folder: string, files: string[], checkFile, cfg) {
|
||||
const subtask = {};
|
||||
const subtasks = [];
|
||||
for (const file of files) {
|
||||
@@ -132,8 +132,8 @@ async function read1(folder: string, files: string[], checkFile) {
|
||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
||||
if (!subtask[REG.subtask(data)]) {
|
||||
subtask[REG.subtask(data)] = [{
|
||||
time_limit_ms: 1000,
|
||||
memory_limit_mb: 512,
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'min',
|
||||
cases: [c],
|
||||
}];
|
||||
@@ -164,7 +164,7 @@ async function read1(folder: string, files: string[], checkFile) {
|
||||
return config;
|
||||
}
|
||||
|
||||
async function readAutoCases(folder, { next }) {
|
||||
async function readAutoCases(folder, { next }, cfg) {
|
||||
const config = {
|
||||
checker_type: 'default',
|
||||
count: 0,
|
||||
@@ -183,8 +183,8 @@ async function readAutoCases(folder, { next }) {
|
||||
const outputs = await fs.readdir(path.resolve(folder, 'output'));
|
||||
files.push(...outputs.map((i) => `output/${i}`));
|
||||
}
|
||||
let result = await read0(folder, files, checkFile);
|
||||
if (!result.count) result = await read1(folder, files, checkFile);
|
||||
let result = await read0(folder, files, checkFile, cfg);
|
||||
if (!result.count) result = await read1(folder, files, checkFile, cfg);
|
||||
Object.assign(config, result);
|
||||
next({ message: { message: 'Found {0} testcases.', params: [config.count] } });
|
||||
} catch (e) {
|
||||
@@ -235,8 +235,8 @@ export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, a
|
||||
for (const c of cfg.cases) {
|
||||
config.count++;
|
||||
config.subtasks[0].cases.push({
|
||||
input: checkFile(c.input, 'Cannot find input file {0}.'),
|
||||
output: checkFile(c.output, 'Cannot find output file {0}.'),
|
||||
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : null,
|
||||
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : null,
|
||||
id: config.count,
|
||||
});
|
||||
}
|
||||
@@ -246,8 +246,8 @@ export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, a
|
||||
for (const c of subtask.cases) {
|
||||
config.count++;
|
||||
cases.push({
|
||||
input: checkFile(c.input, 'Cannot find input file {0}.'),
|
||||
output: checkFile(c.output, 'Cannot find output file {0}.'),
|
||||
input: c.input ? checkFile(c.input, 'Cannot find input file {0}.') : null,
|
||||
output: c.output ? checkFile(c.output, 'Cannot find output file {0}.') : null,
|
||||
id: config.count,
|
||||
});
|
||||
}
|
||||
@@ -260,7 +260,7 @@ export async function readYamlCases(folder: string, cfg: Dictionary<any> = {}, a
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const c = await readAutoCases(folder, { next });
|
||||
const c = await readAutoCases(folder, { next }, cfg);
|
||||
config.subtasks = c.subtasks;
|
||||
config.count = c.count;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ function judgeCase(c, sid) {
|
||||
}
|
||||
const { filename } = ctx.config;
|
||||
const copyIn = { ...ctx.execute.copyIn };
|
||||
if (filename) copyIn[`${filename}.in`] = { src: c.input };
|
||||
if (filename) copyIn[`${filename}.in`] = c.input ? { src: c.input } : { content: '' };
|
||||
const copyOut = filename ? [`${filename}.out`] : [];
|
||||
const stdin = filename ? null : c.input;
|
||||
const stdout = path.resolve(ctx.tmpdir, `${c.id}.out`);
|
||||
|
||||
@@ -17,8 +17,8 @@ const Score = {
|
||||
|
||||
function judgeCase(c) {
|
||||
return async (ctx, ctxSubtask) => {
|
||||
ctx.executeInteractor.copyIn.in = { src: c.input };
|
||||
ctx.executeInteractor.copyIn.out = { src: c.output };
|
||||
ctx.executeInteractor.copyIn.in = c.input ? { src: c.input } : { content: '' };
|
||||
ctx.executeInteractor.copyIn.out = c.output ? { src: c.output } : { content: '' };
|
||||
ctx.executeInteractor.copyIn['testlib.h'] = { src: resolve(__dirname, '../../files/testlib.h') };
|
||||
const [{ code, time_usage_ms, memory_usage_kb }, resInteractor] = await run([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user