diff --git a/README.md b/README.md index 443eb404..f3d08b0a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ Github仓库地址:[https://github.com/HimitZH/HOJ](https://github.com/HimitZH Gitee仓库地址:[https://gitee.com/himitzh0730/hoj](https://gitee.com/himitzh0730/hoj) +**注意:**建议使用Centos8以上或Ubuntu16.04以上的操作系统!!!不然judgeserver可能无法正常启动。 + **有任何部署问题或项目bug请发issue或者加QQ群:598587305进行咨询。** **如果要对本项目进行商业化,请在页面底部的Powered by指向HOJ本仓库地址,顺便点上star收藏本项目对开发者的支持,谢谢。** diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml index fc5e8ab4..409be34f 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/dao/xml/JudgeMapper.xml @@ -3,7 +3,7 @@ - SELECT MAX(score) AS sum_score FROM judge + SELECT MAX(oi_rank_score) AS sum_score FROM judge WHERE uid=#{uid} AND cid=0 AND score IS NOT NULL GROUP BY pid diff --git a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/JudgeVo.java b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/JudgeVo.java index 22c680b5..a0c9b992 100644 --- a/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/JudgeVo.java +++ b/hoj-springboot/DataBackup/src/main/java/top/hcode/hoj/pojo/vo/JudgeVo.java @@ -57,6 +57,9 @@ public class JudgeVo { @ApiModelProperty(value = "题目得分,ACM题目默认为null") private Integer score; + @ApiModelProperty(value = "该题在OI排行榜的分数") + private Integer oiRankScore; + @ApiModelProperty(value = "代码长度") private Integer length; diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeStrategy.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeStrategy.java index f5ebfc4f..174d722d 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeStrategy.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/judge/JudgeStrategy.java @@ -55,13 +55,13 @@ public class JudgeStrategy { // 对用户源代码进行编译 获取tmpfs中的fileId userFileId = Compiler.compile(Constants.CompileConfig.getCompilerByLanguage(judge.getLanguage()), judge.getCode(), judge.getLanguage()); // 测试数据文件所在文件夹 - String testCasesDir = Constants.JudgeDir.TEST_CASE_DIR.getContent() +File.separator+"problem_" + problem.getId(); + String testCasesDir = Constants.JudgeDir.TEST_CASE_DIR.getContent() + File.separator + "problem_" + problem.getId(); // 从文件中加载测试数据json JSONObject testCasesInfo = problemTestCaseUtils.loadTestCaseInfo(problem.getId(), testCasesDir, problem.getCaseVersion(), !StringUtils.isEmpty(problem.getSpjCode())); JSONArray testcaseList = (JSONArray) testCasesInfo.get("testCases"); String version = testCasesInfo.getStr("version"); // 检查是否为spj,同时是否有spj编译完成的文件,若不存在,就先编译生成该spj文件,同时也要检查版本 - Boolean hasSpjOrNotSpj = checkOrCompileSpj(problem,version); + Boolean hasSpjOrNotSpj = checkOrCompileSpj(problem, version); // 如果该题为spj,但是没有spj程序 if (!hasSpjOrNotSpj) { result.put("code", Constants.Judge.STATUS_SYSTEM_ERROR.getStatus()); @@ -133,7 +133,7 @@ public class JudgeStrategy { } - public Boolean checkOrCompileSpj(Problem problem,String version) throws CompileError, SystemError { + public Boolean checkOrCompileSpj(Problem problem, String version) throws CompileError, SystemError { // 如果是需要特判的题目,则需要检测特批程序是否已经编译,否则进行编译 if (!StringUtils.isEmpty(problem.getSpjCode()) || !problem.getCaseVersion().equals(version)) { Constants.CompileConfig spjCompiler = Constants.CompileConfig.getCompilerByLanguage(problem.getSpjLanguage()); @@ -146,7 +146,8 @@ public class JudgeStrategy { } // 获取判题的运行时间,运行空间,OI得分 - public HashMap computeResultInfo(List allTestCaseResultList, Boolean isACM, Integer errorCaseNum, Integer totalScore) { + public HashMap computeResultInfo(List allTestCaseResultList, Boolean isACM, + Integer errorCaseNum, Integer totalScore, Integer problemDiffculty) { HashMap result = new HashMap<>(); // 用时和内存占用保存为多个测试点中最长的 allTestCaseResultList.stream().max(Comparator.comparing(t -> t.getTime())) @@ -157,15 +158,20 @@ public class JudgeStrategy { // OI题目计算得分 if (!isACM) { - // 全对的直接用总分 + // 全对的直接用总分*0.1+2*题目难度 if (errorCaseNum == 0) { + int oiRankScore = (int) Math.round(totalScore * 0.1 + 2 * problemDiffculty); result.put("score", totalScore); + result.put("oiRankScore", oiRankScore); } else { int score = 0; for (JudgeCase testcaseResult : allTestCaseResultList) { score += testcaseResult.getScore(); } + //测试点总得分*0.1+2*题目难度*(测试点总得分/题目总分) + int oiRankScore = (int) Math.round(score * 0.1 + 2 * problemDiffculty * (score * 1.0 / totalScore)); result.put("score", score); + result.put("oiRankScore", oiRankScore); } } return result; @@ -185,7 +191,7 @@ public class JudgeStrategy { Integer time = jsonObject.getLong("time").intValue(); Integer memory = jsonObject.getLong("memory").intValue(); Integer status = jsonObject.getInt("status"); - Long caseId = jsonObject.getLong("caseId",null); + Long caseId = jsonObject.getLong("caseId", null); String inputFileName = jsonObject.getStr("inputFileName"); String outputFileName = jsonObject.getStr("outputFileName"); JudgeCase judgeCase = new JudgeCase(); @@ -218,7 +224,8 @@ public class JudgeStrategy { } // 获取判题的运行时间,运行空间,OI得分 - HashMap result = computeResultInfo(allCaseResList, isACM, errorTestCaseList.size(), problem.getIoScore()); + HashMap result = computeResultInfo(allCaseResList, isACM, errorTestCaseList.size(), + problem.getIoScore(), problem.getDifficulty()); // 如果该题为ACM类型的题目,多个测试点全部正确则AC,否则取第一个错误的测试点的状态 // 如果该题为OI类型的题目, 若多个测试点全部正确则AC,若全部错误则取第一个错误测试点状态,否则为部分正确 diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java index 960331df..9c3b020a 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/service/impl/JudgeServiceImpl.java @@ -74,6 +74,8 @@ public class JudgeServiceImpl extends ServiceImpl implements judge.setTime(Math.min(time, problem.getTimeLimit())); // score judge.setScore((Integer) judgeResult.getOrDefault("score", null)); + // oi_rank_score + judge.setOiRankScore((Integer) judgeResult.getOrDefault("oiRankScore", null)); return judge; } diff --git a/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/Judge.java b/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/Judge.java index de7ce881..71b5ea1c 100644 --- a/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/Judge.java +++ b/hoj-springboot/api/src/main/java/top/hcode/hoj/pojo/entity/Judge.java @@ -89,6 +89,9 @@ public class Judge implements Serializable { @TableField(fill = FieldFill.INSERT) private Integer version; + @TableField(value = "该题在OI排行榜的分数") + private Integer oiRankScore; + @TableField(fill = FieldFill.INSERT) private Date gmtCreate; diff --git a/hoj-vue/src/i18n/oj/en-US.js b/hoj-vue/src/i18n/oj/en-US.js index 848fac39..11dd8787 100644 --- a/hoj-vue/src/i18n/oj/en-US.js +++ b/hoj-vue/src/i18n/oj/en-US.js @@ -226,6 +226,9 @@ export const m = { Enter_Author:'Enter Author', Run_ID:'Run ID', Problem:'Problem', + Problem_Score:'Problem Score', + OI_Rank_Score:'OI Rank Score', + OI_Rank_Calculation_Rule:'OI Rank Calculation Rule', // /views/oj/status/SubmissionDetails.vue Test_point_details:'Test point details', diff --git a/hoj-vue/src/i18n/oj/zh-CN.js b/hoj-vue/src/i18n/oj/zh-CN.js index f6923f40..fbac74f8 100644 --- a/hoj-vue/src/i18n/oj/zh-CN.js +++ b/hoj-vue/src/i18n/oj/zh-CN.js @@ -228,6 +228,10 @@ export const m = { Enter_Author:'请输入作者', Run_ID:'Run ID', Problem:'题目', + Problem_Score:'OI题目总得分', + OI_Rank_Score:'OI排行榜得分', + OI_Rank_Calculation_Rule:'OI排行得分计算公式', + // /views/oj/status/SubmissionDetails.vue Test_point_details:'测试点详情', diff --git a/hoj-vue/src/views/oj/status/SubmissionDetails.vue b/hoj-vue/src/views/oj/status/SubmissionDetails.vue index f2cbe32d..ac164ecc 100644 --- a/hoj-vue/src/views/oj/status/SubmissionDetails.vue +++ b/hoj-vue/src/views/oj/status/SubmissionDetails.vue @@ -97,7 +97,19 @@ v-if="isIOProblem" > diff --git a/hoj-vue/src/views/oj/status/SubmissionList.vue b/hoj-vue/src/views/oj/status/SubmissionList.vue index 78021bc5..12d73d98 100644 --- a/hoj-vue/src/views/oj/status/SubmissionList.vue +++ b/hoj-vue/src/views/oj/status/SubmissionList.vue @@ -159,12 +159,26 @@