Skip to content

Commit

Permalink
answer show
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoGeNintendo committed Jan 11, 2020
1 parent cd6a7e6 commit d427576
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion WebContent/plist.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
for(Problem p:allP){
%>
<a href="pview.jsp?set=<%=res %>&id=<%=p.id %>"><%=p.id+" - "+p.name %></a>
<a href="pview.jsp?set=<%=res %>&id=<%=p.id %>"><%=p.id+" - "+p.name %></a> <br/>
<%
}
}catch(Exception e){
Expand Down
4 changes: 4 additions & 0 deletions WebContent/sview.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Language:<%=s.lang %><br/>
Time:<%=s.getRunTime() %><br/>
Memory:<%=s.getRunMem() %><br/>
Judger:<%=s.judger %> <br/>

<h2>Code</h2>
<pre><%=s.code.replace("<", "&lt;").replace(">","&gt;") %>
Expand All @@ -73,6 +74,9 @@
<h5>Output</h5>
<pre><%=tr.output.replace("<", "&lt;").replace(">","&gt;") %>
</pre>
<h5>Answer</h5>
<pre><%=tr.answer.replace("<", "&lt;").replace(">","&gt;") %>
</pre>
<h5>Checker Information</h5>
<pre><%=tr.info.replace("<", "&lt;").replace(">","&gt;") %>
</pre>
Expand Down
8 changes: 7 additions & 1 deletion src/com/hhs/xgn/hhsoj/essential/common/TestResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public class TestResult {
* The output file (1KB)
*/
public String output="";
/**
* The answer file (1KB)
*/
public String answer="";

/**
* The score
*/
Expand All @@ -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(){
Expand Down
21 changes: 11 additions & 10 deletions src/com/hhs/xgn/hhsoj/essential/judge/JudgeServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand All @@ -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"));
Expand All @@ -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){
Expand Down
2 changes: 1 addition & 1 deletion src/com/hhs/xgn/hhsoj/essential/se/Judger.java
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/hhs/xgn/hhsoj/essential/se/JudgingThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions src/com/hhs/xgn/hhsoj/essential/se/ServerManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public synchronized void notifyJudge(){

for(int i=0;i<judgers.size();i++){
if(!judgers.get(i).isOnline()){ //kill offline judges
System.out.println("Killed judge:"+judgers.get(i).name);
judgers.remove(i);
i--;
continue;
Expand Down

0 comments on commit d427576

Please sign in to comment.