t123yh
7 years ago
3 changed files with 53 additions and 3 deletions
@ -0,0 +1,6 @@
|
||||
var ProblemType; |
||||
(function (ProblemType) { |
||||
ProblemType[ProblemType["Standard"] = 1] = "Standard"; |
||||
ProblemType[ProblemType["AnswerSubmission"] = 2] = "AnswerSubmission"; |
||||
ProblemType[ProblemType["Interaction"] = 3] = "Interaction"; |
||||
})(ProblemType = exports.ProblemType || (exports.ProblemType = {})); |
@ -0,0 +1,44 @@
|
||||
const enums = require('./enums'), |
||||
rp = require('request-promise'), |
||||
url = require('url'); |
||||
|
||||
module.exports.judge = async function (judge_state, priority) { |
||||
let type, param; |
||||
switch (judge_state.problem.type) { |
||||
case 'submit-answer': |
||||
type = enums.ProblemType.AnswerSubmission; |
||||
break; |
||||
case 'interaction': |
||||
type = enums.ProblemType.Interaction; |
||||
break; |
||||
default: |
||||
type = enums.ProblemType.Standard; |
||||
param = { |
||||
language: judge_state.language, |
||||
code: judge_state.code, |
||||
timeLimit: judge_state.problem.time_limit, |
||||
memoryLimit: judge_state.problem.memory_limit, |
||||
fileIOInput: judge_state.problem.file_io ? judge_state.problem.file_io_input_name : null, |
||||
fileIOOutput: judge_state.problem.file_io ? judge_state.problem.file_io_output_name : null |
||||
}; |
||||
break; |
||||
} |
||||
|
||||
const req = { |
||||
taskId: judge_state.id, |
||||
testData: judge_state.problem.id.toString(), |
||||
type: type, |
||||
priority: priority, |
||||
param: param |
||||
}; |
||||
|
||||
await rp(url.resolve(syzoj.config.judge_server_addr, "/daemon/task"), { |
||||
method: 'PUT', |
||||
body: req, |
||||
headers: { |
||||
Token: syzoj.config.judge_token |
||||
}, |
||||
json: true, |
||||
simple: true |
||||
}); |
||||
} |
Loading…
Reference in new issue