|
|
|
@ -27,8 +27,8 @@ let judgeQueue;
|
|
|
|
|
|
|
|
|
|
async function connect() { |
|
|
|
|
const JudgeState = syzoj.model('judge_state'); |
|
|
|
|
|
|
|
|
|
const blockableRedisClient = syzoj.redis.duplicate(); |
|
|
|
|
|
|
|
|
|
const blockableRedisClient = syzoj.redis.duplicate(); |
|
|
|
|
judgeQueue = { |
|
|
|
|
redisZADD: util.promisify(syzoj.redis.zadd).bind(syzoj.redis), |
|
|
|
|
redisBZPOPMAX: util.promisify(blockableRedisClient.bzpopmax).bind(blockableRedisClient), |
|
|
|
@ -174,7 +174,7 @@ async function connect() {
|
|
|
|
|
if (!judge_state) return; |
|
|
|
|
const problemId = judge_state.problem_id; |
|
|
|
|
let problemQuery = await Problem.createQueryBuilder(); |
|
|
|
|
const problemInfo = await problemQuery.where("id = :id", { id: problemId }).getOne(); |
|
|
|
|
const problemInfo = await problemQuery.where("id = :id", {id: problemId}).getOne(); |
|
|
|
|
const problem_time_limit = problemInfo.time_limit; |
|
|
|
|
const subtasksArray = convertedResult.result.judge ? convertedResult.result.judge.subtasks : []; |
|
|
|
|
const timeArray = subtasksArray.map((subtasksItem) => { |
|
|
|
@ -182,9 +182,10 @@ async function connect() {
|
|
|
|
|
return subtasksItemCases.result.time |
|
|
|
|
}) |
|
|
|
|
}); |
|
|
|
|
function flat(array, result=[]){ |
|
|
|
|
for (let i=0;i<array.length;i++){ |
|
|
|
|
if (Array.isArray(array[i])){ |
|
|
|
|
|
|
|
|
|
function flat(array, result = []) { |
|
|
|
|
for (let i = 0; i < array.length; i++) { |
|
|
|
|
if (Array.isArray(array[i])) { |
|
|
|
|
flat(array[i], result); |
|
|
|
|
} else { |
|
|
|
|
result.push(array[i]); |
|
|
|
@ -192,23 +193,27 @@ async function connect() {
|
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const flatTimeArray = flat(timeArray); |
|
|
|
|
const maxItemTime = Math.max.apply(this, flatTimeArray); |
|
|
|
|
let baseScore = 0; |
|
|
|
|
if (judge_state.type === 0) { |
|
|
|
|
if (judge_state.type === 0 || judge_state.type === 1) { |
|
|
|
|
baseScore = 100; |
|
|
|
|
} |
|
|
|
|
if (judge_state.type === 2) { |
|
|
|
|
baseScore = syzoj.config.practice_rating |
|
|
|
|
} |
|
|
|
|
if (convertedResult.statusString === 'Accepted' && maxItemTime < problem_time_limit * 0.9) { |
|
|
|
|
if (convertedResult.statusString === 'Accepted' && maxItemTime < problem_time_limit * 0.9) |
|
|
|
|
{ |
|
|
|
|
const beyondTime = problem_time_limit - maxItemTime; |
|
|
|
|
const extraScore = (beyondTime / problem_time_limit).toString().slice(0,3)*baseScore; |
|
|
|
|
const extraScore = (beyondTime / problem_time_limit).toString().slice(0, 3) * baseScore; |
|
|
|
|
if (judge_state.type === 2) { |
|
|
|
|
judge_state.score = convertedResult.score + extraScore + syzoj.config.practice_rating; |
|
|
|
|
} |
|
|
|
|
judge_state.score = convertedResult.score + extraScore; |
|
|
|
|
} else { |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
judge_state.score = convertedResult.score; |
|
|
|
|
} |
|
|
|
|
judge_state.pending = false; |
|
|
|
|