mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
1 parent
d5c5b3fd47
commit
1c89596cb3
20 files changed
+84
-59
No files matched your search
@@ -88,8 +88,8 @@ async function read0(folder: string, files: string[], checkFile, cfg) {
|
||||
const config = {
|
||||
count: 0,
|
||||
subtasks: [{
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
time: parseTimeMS(cfg.time || '1s'),
|
||||
memory: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'sum',
|
||||
cases: [],
|
||||
score: Math.floor(100 / cases.length),
|
||||
@@ -105,8 +105,8 @@ async function read0(folder: string, files: string[], checkFile, cfg) {
|
||||
}
|
||||
if (extra < cases.length) {
|
||||
config.subtasks.push({
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
time: parseTimeMS(cfg.time || '1s'),
|
||||
memory: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'sum',
|
||||
cases: [],
|
||||
score: Math.floor(100 / cases.length) + 1,
|
||||
@@ -134,8 +134,8 @@ async function read1(folder: string, files: string[], checkFile, cfg) {
|
||||
if (fs.existsSync(path.resolve(folder, c.output))) {
|
||||
if (!subtask[REG.subtask(data)]) {
|
||||
subtask[REG.subtask(data)] = [{
|
||||
time_limit_ms: parseTimeMS(cfg.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(cfg.memory || '256m'),
|
||||
time: parseTimeMS(cfg.time || '1s'),
|
||||
memory: parseMemoryMB(cfg.memory || '256m'),
|
||||
type: 'min',
|
||||
cases: [c],
|
||||
}];
|
||||
@@ -199,7 +199,7 @@ function isValidConfig(config) {
|
||||
if (config.count > (getConfig('testcases_max') || 100)) {
|
||||
throw new FormatError('Too many testcases. Cancelled.');
|
||||
}
|
||||
const total_time = sum(config.subtasks.map((subtask) => subtask.time_limit_ms * subtask.cases.length));
|
||||
const total_time = sum(config.subtasks.map((subtask) => subtask.time * subtask.cases.length));
|
||||
if (total_time > (getConfig('total_time_limit') || 60) * 1000) {
|
||||
throw new FormatError('Total time limit longer than {0}s. Cancelled.', [+getConfig('total_time_limit') || 60]);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ function judgeCase(c, sid) {
|
||||
stderr,
|
||||
copyIn,
|
||||
copyOut,
|
||||
time_limit_ms: ctxSubtask.subtask.time_limit_ms * ctx.execute.time,
|
||||
memory_limit_mb: ctxSubtask.subtask.memory_limit_mb,
|
||||
time: ctxSubtask.subtask.time * ctx.execute.time,
|
||||
memory: ctxSubtask.subtask.memory,
|
||||
},
|
||||
);
|
||||
const { code, time_usage_ms, memory_usage_kb } = res;
|
||||
@@ -62,9 +62,9 @@ function judgeCase(c, sid) {
|
||||
let message: any = '';
|
||||
let score = 0;
|
||||
if (status === STATUS.STATUS_ACCEPTED) {
|
||||
if (time_usage_ms > ctxSubtask.subtask.time_limit_ms * ctx.execute.time) {
|
||||
if (time_usage_ms > ctxSubtask.subtask.time * ctx.execute.time) {
|
||||
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
||||
} else if (memory_usage_kb > ctxSubtask.subtask.memory_limit_mb * 1024) {
|
||||
} else if (memory_usage_kb > ctxSubtask.subtask.memory * 1024) {
|
||||
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
||||
} else {
|
||||
[status, score, message] = await check({
|
||||
|
||||
@@ -77,8 +77,8 @@ export const judge = async (ctx) => {
|
||||
stderr,
|
||||
copyIn: execute.copyIn,
|
||||
copyOut,
|
||||
time_limit_ms: 1000,
|
||||
memory_limit_mb: 512,
|
||||
time: 1000,
|
||||
memory: 512,
|
||||
},
|
||||
);
|
||||
const { code, time_usage_ms, memory_usage_kb } = res;
|
||||
|
||||
@@ -24,21 +24,21 @@ function judgeCase(c) {
|
||||
{
|
||||
execute: ctx.executeUser.execute.replace(/\$\{name\}/g, 'code'),
|
||||
copyIn: ctx.executeUser.copyIn,
|
||||
time_limit_ms: ctxSubtask.subtask.time_limit_ms,
|
||||
memory_limit_mb: ctxSubtask.subtask.memory_limit_mb,
|
||||
time: ctxSubtask.subtask.time,
|
||||
memory: ctxSubtask.subtask.memory,
|
||||
}, {
|
||||
execute: `${ctx.executeInteractor.execute.replace(/\$\{name\}/g, 'interactor')} /w/in /w/tout`,
|
||||
copyIn: ctx.executeInteractor.copyIn,
|
||||
time_limit_ms: ctxSubtask.subtask.time_limit_ms * 2,
|
||||
memory_limit_mb: ctxSubtask.subtask.memory_limit_mb * 2,
|
||||
time: ctxSubtask.subtask.time * 2,
|
||||
memory: ctxSubtask.subtask.memory * 2,
|
||||
},
|
||||
]);
|
||||
let status;
|
||||
let score = 0;
|
||||
let message: any = '';
|
||||
if (time_usage_ms > ctxSubtask.subtask.time_limit_ms) {
|
||||
if (time_usage_ms > ctxSubtask.subtask.time) {
|
||||
status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
||||
} else if (memory_usage_kb > ctxSubtask.subtask.memory_limit_mb * 1024) {
|
||||
} else if (memory_usage_kb > ctxSubtask.subtask.memory * 1024) {
|
||||
status = STATUS.STATUS_MEMORY_LIMIT_EXCEEDED;
|
||||
} else if (code) {
|
||||
status = STATUS.STATUS_RUNTIME_ERROR;
|
||||
|
||||
@@ -69,8 +69,8 @@ export const judge = async (ctx) => {
|
||||
stderr,
|
||||
copyIn,
|
||||
copyOut,
|
||||
time_limit_ms: parseTimeMS(ctx.config.time || '1s'),
|
||||
memory_limit_mb: parseMemoryMB(ctx.config.memory || '128m'),
|
||||
time: parseTimeMS(ctx.config.time || '1s'),
|
||||
memory: parseMemoryMB(ctx.config.memory || '128m'),
|
||||
},
|
||||
);
|
||||
const { code, time_usage_ms, memory_usage_kb } = res;
|
||||
|
||||
@@ -25,8 +25,8 @@ const statusMap = {
|
||||
|
||||
function proc({
|
||||
execute = '',
|
||||
time_limit_ms = 16000,
|
||||
memory_limit_mb = 1024,
|
||||
time = 16000,
|
||||
memory = 1024,
|
||||
process_limit = 32,
|
||||
stdin = '', copyIn = {}, copyOut = [], copyOutCached = [],
|
||||
} = {}) {
|
||||
@@ -39,9 +39,9 @@ function proc({
|
||||
{ name: 'stdout', max: 1024 * 1024 * size },
|
||||
{ name: 'stderr', max: 1024 * 1024 * size },
|
||||
],
|
||||
cpuLimit: time_limit_ms * 1000 * 1000,
|
||||
realCpuLimit: time_limit_ms * 3000 * 1000,
|
||||
memoryLimit: memory_limit_mb * 1024 * 1024,
|
||||
cpuLimit: time * 1000 * 1000,
|
||||
realCpuLimit: time * 3000 * 1000,
|
||||
memoryLimit: memory * 1024 * 1024,
|
||||
procLimit: process_limit,
|
||||
copyIn,
|
||||
copyOut,
|
||||
@@ -58,7 +58,7 @@ async function adaptResult(result, params) {
|
||||
files: result.files,
|
||||
code: result.exitStatus,
|
||||
};
|
||||
if (ret.time_usage_ms >= (params.time_limit_ms || 16000)) {
|
||||
if (ret.time_usage_ms >= (params.time || 16000)) {
|
||||
ret.status = STATUS.STATUS_TIME_LIMIT_EXCEEDED;
|
||||
}
|
||||
ret.files = result.files || {};
|
||||
|
||||
Reference in new issue
Block a user