Browse Source

update: 计算额外加分时改用最大单项时间为基准。

feature/unlimited-reply
zjz1993 5 years ago
parent
commit
3e70e90f9a
  1. 22
      libs/judger.js

22
libs/judger.js

@ -176,8 +176,26 @@ async function connect() {
let problemQuery = await Problem.createQueryBuilder();
const problemInfo = await problemQuery.where("id = :id", { id: problemId }).getOne();
const problem_time_limit = problemInfo.time_limit;
if (judge_state.type_info && convertedResult.statusString === 'Accepted' && convertedResult.time < problem_time_limit * 0.9) {
const beyondTime = problem_time_limit - convertedResult.time;
const subtasksArray = convertedResult.result.judge.subtasks;
const timeArray = subtasksArray.map((subtasksItem) => {
return subtasksItem.cases.map((subtasksItemCases) => {
return subtasksItemCases.result.time
})
});
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]);
}
}
return result;
}
const flatTimeArray = flat(timeArray);
const maxItemTime = Math.max.apply(this, flatTimeArray);
if (judge_state.type_info && 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)*100;
judge_state.score = convertedResult.score + extraScore;
} else {

Loading…
Cancel
Save