From d4275767a45a402526d1903a723758b70a3c5215 Mon Sep 17 00:00:00 2001 From: XiaoGeNintendo <34835642+XiaoGeNintendo@users.noreply.github.com> Date: Sat, 11 Jan 2020 17:38:42 +0800 Subject: [PATCH] answer show --- WebContent/plist.jsp | 2 +- WebContent/sview.jsp | 4 ++++ .../hhsoj/essential/common/TestResult.java | 8 ++++++- .../hhsoj/essential/judge/JudgeServer.java | 21 ++++++++++--------- .../hhs/xgn/hhsoj/essential/se/Judger.java | 2 +- .../xgn/hhsoj/essential/se/JudgingThread.java | 2 +- .../xgn/hhsoj/essential/se/ServerManager.java | 1 + 7 files changed, 26 insertions(+), 14 deletions(-) diff --git a/WebContent/plist.jsp b/WebContent/plist.jsp index 74619dc..d3e335a 100644 --- a/WebContent/plist.jsp +++ b/WebContent/plist.jsp @@ -24,7 +24,7 @@ for(Problem p:allP){ %> - <%=p.id+" - "+p.name %> + <%=p.id+" - "+p.name %>
<% } }catch(Exception e){ diff --git a/WebContent/sview.jsp b/WebContent/sview.jsp index ec06785..21d8a8b 100644 --- a/WebContent/sview.jsp +++ b/WebContent/sview.jsp @@ -48,6 +48,7 @@ Language:<%=s.lang %>
Time:<%=s.getRunTime() %>
Memory:<%=s.getRunMem() %>
+ Judger:<%=s.judger %>

Code

<%=s.code.replace("<", "<").replace(">",">") %>
@@ -73,6 +74,9 @@
 				
Output
<%=tr.output.replace("<", "<").replace(">",">") %>
 				
+
Answer
+
<%=tr.answer.replace("<", "<").replace(">",">") %>
+				
Checker Information
<%=tr.info.replace("<", "<").replace(">",">") %>
 				
diff --git a/src/com/hhs/xgn/hhsoj/essential/common/TestResult.java b/src/com/hhs/xgn/hhsoj/essential/common/TestResult.java index 5e55714..33668ab 100644 --- a/src/com/hhs/xgn/hhsoj/essential/common/TestResult.java +++ b/src/com/hhs/xgn/hhsoj/essential/common/TestResult.java @@ -21,6 +21,11 @@ public class TestResult { * The output file (1KB) */ public String output=""; + /** + * The answer file (1KB) + */ + public String answer=""; + /** * The score */ @@ -35,13 +40,14 @@ public TestResult(String verdict, int time, int memory, String info, String inpu this.score = score; } - public TestResult(String verdict, String time, String memory, String info, String input, String output, float score) { + public TestResult(String verdict, String time, String memory, String info, String input,String answer, String output, float score) { this.verdict = verdict; this.time = Integer.parseInt(time); this.memory = Integer.parseInt(memory); this.info = info; this.input = input; this.output = output; + this.answer = answer; this.score = score; } public TestResult(){ diff --git a/src/com/hhs/xgn/hhsoj/essential/judge/JudgeServer.java b/src/com/hhs/xgn/hhsoj/essential/judge/JudgeServer.java index 2e8a84f..6313b4f 100644 --- a/src/com/hhs/xgn/hhsoj/essential/judge/JudgeServer.java +++ b/src/com/hhs/xgn/hhsoj/essential/judge/JudgeServer.java @@ -140,7 +140,7 @@ boolean runSingleTest(Submission sub,int id,File set,Problem pr) { addAll(cmd,r); - System.out.println("Start running core with arg:"+cmd); +// System.out.println("Start running core with arg:"+cmd); ProcessBuilder pb=new ProcessBuilder(cmd); pb.directory(new File("judge")); pb.redirectOutput(new File("judge/sbout.txt")); @@ -161,28 +161,29 @@ boolean runSingleTest(Submission sub,int id,File set,Problem pr) { String sbout=CommonUtil.readFile("judge/sbout.txt"); String[] arg=sbout.split("\n"); if(arg[0].equals("RE")){ - sub.addResult(sn,new TestResult("Runtime Error", arg[1],arg[2], "Exit code is "+arg[3], inp, "", 0)); + sub.addResult(sn,new TestResult("Runtime Error", arg[1],arg[2], "Exit code is "+arg[3], inp, "", "",0)); return false; } if(arg[0].equals("RF")){ - sub.addResult(sn,new TestResult("Restrict Function", arg[1],arg[2], arg[3], inp, "", 0)); + sub.addResult(sn,new TestResult("Restrict Function", arg[1],arg[2], arg[3], inp, "", "",0)); return false; } if(arg[0].equals("TLE")){ - sub.addResult(sn,new TestResult("Time Limit Exceeded", arg[1],arg[2], "", inp, "", 0)); + sub.addResult(sn,new TestResult("Time Limit Exceeded", arg[1],arg[2], "", inp, "", "",0)); return false; } if(arg[0].equals("MLE")){ - sub.addResult(sn,new TestResult("Memory Limit Exceeded", arg[1],arg[2], "", inp, "", 0)); + sub.addResult(sn,new TestResult("Memory Limit Exceeded", arg[1],arg[2], "", inp, "", "",0)); return false; } if(arg[0].equals("UKE")){ - sub.addResult(sn,new TestResult("Judgement Failed", arg[1], arg[2], "Please send an issue with this information:"+arg[3], "", "", 0)); + sub.addResult(sn,new TestResult("Judgement Failed", arg[1], arg[2], "Please send an issue with this information:"+arg[3], "", "", "",0)); return false; } //next is compare answers String oup=CommonUtil.readFileWithLimit("judge/out.txt",1024); + String ans=CommonUtil.readFileWithLimit("judge/ans.txt", 1024); ProcessBuilder pb2=new ProcessBuilder("./checker","in.txt","out.txt","ans.txt","report.txt"); pb2.directory(new File("judge")); @@ -195,19 +196,19 @@ boolean runSingleTest(Submission sub,int id,File set,Problem pr) { String info=CommonUtil.readFileWithLimit("judge/report.txt", 1024); if(p2.exitValue()==0){ - sub.addResult(sn,new TestResult("Accepted", arg[1],arg[2], info, inp, oup, 1)); + sub.addResult(sn,new TestResult("Accepted", arg[1],arg[2], info, inp, oup,ans, 1)); return true; }else{ if(p2.exitValue()==7){ - sub.addResult(sn,new TestResult("Point", arg[1],arg[2], info, inp, oup, Float.parseFloat(info.split(" ")[0]))); + sub.addResult(sn,new TestResult("Point", arg[1],arg[2], info, inp, oup, ans,Float.parseFloat(info.split(" ")[0]))); return true; }else{ - sub.addResult(sn,new TestResult("Wrong Answer", arg[1],arg[2], info, inp, oup, 0)); + sub.addResult(sn,new TestResult("Wrong Answer", arg[1],arg[2], info, inp, oup, ans,0)); return false; } } }else{ - sub.addResult(sn,new TestResult("Checker Time Limit Exceeded", arg[1],arg[2], "", inp, oup, 0)); + sub.addResult(sn,new TestResult("Checker Time Limit Exceeded", arg[1],arg[2], "", inp, oup, ans,0)); return false; } }catch(Exception e){ diff --git a/src/com/hhs/xgn/hhsoj/essential/se/Judger.java b/src/com/hhs/xgn/hhsoj/essential/se/Judger.java index 3c63d33..b0120d2 100644 --- a/src/com/hhs/xgn/hhsoj/essential/se/Judger.java +++ b/src/com/hhs/xgn/hhsoj/essential/se/Judger.java @@ -38,7 +38,7 @@ public Judger(String name,Socket sock,DataInputStream dis,DataOutputStream dos){ } public boolean isOnline() { - return !sock.isClosed(); + return !sock.isClosed() || !sock.isInputShutdown() || !sock.isOutputShutdown(); } public void work(Submission submission,ServerManager boss) { diff --git a/src/com/hhs/xgn/hhsoj/essential/se/JudgingThread.java b/src/com/hhs/xgn/hhsoj/essential/se/JudgingThread.java index b387e0c..d6131bc 100644 --- a/src/com/hhs/xgn/hhsoj/essential/se/JudgingThread.java +++ b/src/com/hhs/xgn/hhsoj/essential/se/JudgingThread.java @@ -99,7 +99,7 @@ public void run(){ while(true){ sub=gs.fromJson(j.dis.readUTF(), Submission.class); boss.saveSubmission(sub); - System.out.println("Received:"+gs.toJson(sub)); +// System.out.println("Received:"+gs.toJson(sub)); if(sub.isFinal){ break; } diff --git a/src/com/hhs/xgn/hhsoj/essential/se/ServerManager.java b/src/com/hhs/xgn/hhsoj/essential/se/ServerManager.java index 40f892a..7acaf49 100644 --- a/src/com/hhs/xgn/hhsoj/essential/se/ServerManager.java +++ b/src/com/hhs/xgn/hhsoj/essential/se/ServerManager.java @@ -57,6 +57,7 @@ public synchronized void notifyJudge(){ for(int i=0;i