Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions server/judge_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ def _compare_output(self, test_case_file_id):
with open(user_output_file, "rb") as f:
content = f.read()
output_md5 = hashlib.md5(content.rstrip()).hexdigest()
result = output_md5 == self._get_test_case_file_info(test_case_file_id)["stripped_output_md5"]
return output_md5, result
all_stripped_md5 = hashlib.md5(b'\n'.join([x.rstrip() for x in content.split(b'\n') if len(x) > 0])).hexdigest()
is_ac = output_md5 == self._get_test_case_file_info(test_case_file_id)["stripped_output_md5"]
is_pe = all_stripped_md5 == self._get_test_case_file_info(test_case_file_id)["all_stripped_output_md5"]
return output_md5, is_ac, is_pe

def _spj(self, in_file_path, user_out_file_path):
os.chown(self._submission_dir, SPJ_USER_UID, 0)
Expand Down Expand Up @@ -138,10 +140,12 @@ def _judge_one(self, test_case_file_id):
run_result["result"] = _judger.RESULT_SYSTEM_ERROR
run_result["error"] = _judger.ERROR_SPJ_ERROR
else:
run_result["output_md5"], is_ac = self._compare_output(test_case_file_id)
run_result["output_md5"], is_ac, is_pe = self._compare_output(test_case_file_id)
# -1 == Wrong Answer
if not is_ac:
run_result["result"] = _judger.RESULT_WRONG_ANSWER
if not is_ac and is_pe:
run_result["result"] = _judger.RESULT_PRESENTATION_ERROR

if self._output:
try:
Expand Down