Skip to content

Commit

Permalink
fix generate
Browse files Browse the repository at this point in the history
  • Loading branch information
pandadtdyy committed Dec 13, 2023
1 parent 1cfd99e commit da62b55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
19 changes: 5 additions & 14 deletions packages/hydrojudge/src/judge/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ export const judge = async (ctx: JudgeTask) => {
ctx.compileLocalFile('std', std),
]);
ctx.next({ status: STATUS.STATUS_JUDGING, progress: 0 });
const { address_space_limit, process_limit } = ctx.session.getLang(ctx.lang);
let totalTime = 0;
let totalMemory = 0;
let totalStatus = STATUS.STATUS_JUDGING;
let totalStatus = 0;

async function runGenerator(i: number) {
const res = await runQueued(
`${executeGenerator} ${i}`,
`${executeGenerator.execute} ${i}`,
{
stdin: { content: ctx.input },
stdin: { content: ctx.input || '' },
copyIn: executeGenerator.copyIn,
copyOut: ['stdout'],
time: parseTimeMS('2s'),
memory: parseMemoryMB('256m'),
addressSpaceLimit: address_space_limit,
processLimit: process_limit,
},
1,
);
Expand Down Expand Up @@ -68,8 +65,6 @@ export const judge = async (ctx: JudgeTask) => {
await ctx.session.postFile(ctx.request.rid.toString(), `${i}.in`, tmp);
}
ctx.next({
status: totalStatus,
score: 0,
case: {
id: i,
subtaskId: 1,
Expand All @@ -84,15 +79,13 @@ export const judge = async (ctx: JudgeTask) => {
}
async function runStd(i: number, stdin: CopyInFile) {
const res = await runQueued(
`${executeStd} ${i}`,
`${executeStd.execute} ${i}`,
{
stdin,
copyIn: executeStd.copyIn,
copyOut: ['stdout'],
time: parseTimeMS('2s'),
memory: parseMemoryMB('256m'),
addressSpaceLimit: address_space_limit,
processLimit: process_limit,
},
1,
);
Expand Down Expand Up @@ -123,8 +116,6 @@ export const judge = async (ctx: JudgeTask) => {
await ctx.session.postFile(ctx.request.rid.toString(), `${i}.out`, tmp);
}
ctx.next({
status: totalStatus,
score: 0,
case: {
id: i,
subtaskId: 2,
Expand All @@ -146,7 +137,7 @@ export const judge = async (ctx: JudgeTask) => {
if (process.env.DEV) ctx.next({ message: JSON.stringify(ctx.stat) });
ctx.end({
status: totalStatus,
score: 100,
score: totalStatus === STATUS.STATUS_ACCEPTED ? 100 : 0,
time: totalTime,
memory: totalMemory,
});
Expand Down
4 changes: 2 additions & 2 deletions packages/hydrojudge/src/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ export class JudgeTask {
isSelfSubmission: this.meta.problemOwner === this.request.uid,
key: md5(`${this.source}/${getConfig('secret')}`),
lang: this.lang,
langConfig: (this.request.type !== 'generate' && ['objective', 'submit_answer'].includes(this.request.config.type))
langConfig: (this.request.type === 'generate' || ['objective', 'submit_answer'].includes(this.request.config.type))
? null : this.session.getLang(this.lang),
},
);
this.stat.judge = new Date();
const type = this.request.contest?.toString() === '000000000000000000000000' ? 'run'
: this.request.contest?.toString() === '000000000000000000000001' ? 'generate'
: this.request.type === 'generate' ? 'generate'
: this.files?.hack ? 'hack'
: this.config.type || 'default';
if (!judge[type]) throw new FormatError('Unrecognized problemType: {0}', [type]);
Expand Down

0 comments on commit da62b55

Please sign in to comment.