From 112320d4243e269de4c46d6087f1ad4bd0934bc8 Mon Sep 17 00:00:00 2001 From: Himit_ZH <372347736@qq.com> Date: Sat, 3 Jul 2021 22:24:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DHDU,POJ=E6=97=B6=E9=97=B4?= =?UTF-8?q?=EF=BC=8C=E5=86=85=E5=AD=98=E8=AE=B0=E5=BD=95=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../top/hcode/hoj/remoteJudge/task/Impl/HduJudge.java | 9 +++++---- .../top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/HduJudge.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/HduJudge.java index 4c01e032..e6678920 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/HduJudge.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/HduJudge.java @@ -85,11 +85,11 @@ public class HduJudge implements RemoteJudgeStrategy { HttpResponse response = request.execute(); // 1提交时间 2结果 3执行时间 4执行空间 5代码长度 // 一般情况下 代码长度和提交时间不需要,想要也行,自行添加 - Pattern pattern = Pattern.compile(">" + submitId + "([\\s\\S]*?)([\\s\\S]*?)[\\s\\S]*?(\\d*?)MS(\\d*?)K(\\d*?)B"); + Pattern pattern = Pattern.compile(">" + submitId + "[\\s\\S]*?([\\s\\S]*?)[\\s\\S]*?(\\d*?)MS(\\d*?)K"); Matcher matcher = pattern.matcher(response.body()); // 找到时 Validate.isTrue(matcher.find()); - String rawStatus = matcher.group(2).replaceAll("<[\\s\\S]*?>", "").trim(); + String rawStatus = matcher.group(1).replaceAll("<[\\s\\S]*?>", "").trim(); Constants.Judge statusType = statusTypeMap.get(rawStatus); if (statusType == Constants.Judge.STATUS_PENDING) { return MapUtil.builder(new HashMap()) @@ -99,10 +99,11 @@ public class HduJudge implements RemoteJudgeStrategy { Map result = MapUtil.builder(new HashMap()) .put("status", statusType.getStatus()).build(); // 获取其他信息 - String executionTime = matcher.group(3); + String executionTime = matcher.group(2); result.put("time", Integer.parseInt(executionTime)); - String executionMemory = matcher.group(4); + String executionMemory = matcher.group(3); result.put("memory", Integer.parseInt(executionMemory)); + // 如果CE了,则还需要获得错误信息 if (statusType == Constants.Judge.STATUS_COMPILE_ERROR) { request.setUrl(HOST + String.format(ERROR_URL, submitId)); diff --git a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java index 2e2f01dd..0895cf2f 100644 --- a/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java +++ b/hoj-springboot/JudgeServer/src/main/java/top/hcode/hoj/remoteJudge/task/Impl/POJJudge.java @@ -105,10 +105,10 @@ public class POJJudge implements RemoteJudgeStrategy { result.put("CEInfo", HtmlUtil.unescape(compilationErrorInfo)); } else { // 如果不是CE,获取其他信息 - String executionTime = ReUtil.get("Memory: ([-\\d]+)", response.body(), 1); - result.put("time", executionTime == null ? null : Integer.parseInt(executionTime)); - String executionMemory = ReUtil.get("Time: ([-\\d]+)", response.body(), 1); + String executionMemory = ReUtil.get("Memory: ([-\\d]+)", response.body(), 1); result.put("memory", executionMemory == null ? null : Integer.parseInt(executionMemory)); + String executionTime = ReUtil.get("Time: ([-\\d]+)", response.body(), 1); + result.put("time", executionTime == null ? null : Integer.parseInt(executionTime)); } return result; }