mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
Merge d92d5a1b39 into df873278ab
This commit is contained in:
commit
c267c04c62
@ -172,6 +172,10 @@ class JudgeDispatcher(DispatcherBase):
|
||||
resp["data"].sort(key=lambda x: int(x["test_case"]))
|
||||
self.submission.info = resp
|
||||
self._compute_statistic_info(resp["data"])
|
||||
if self.problem.pe_ignored:
|
||||
for case in resp["data"]:
|
||||
if case["result"] is JudgeStatus.PRESNTATION_ERROR:
|
||||
case["result"] = 0
|
||||
error_test_case = list(filter(lambda case: case["result"] != 0, resp["data"]))
|
||||
# ACM模式下,多个测试点全部正确则AC,否则取第一个错误的测试点的状态
|
||||
# OI模式下, 若多个测试点全部正确则AC, 若全部错误则取第一个错误测试点状态,否则为部分正确
|
||||
|
||||
45
problem/migrations/0013_auto_20181227_0719.py
Normal file
45
problem/migrations/0013_auto_20181227_0719.py
Normal file
@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.4 on 2018-12-27 07:19
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
from django.conf import settings
|
||||
import os
|
||||
import json
|
||||
import hashlib
|
||||
|
||||
|
||||
def update_all_stripped_md5(apps, schema_editor):
|
||||
Problem = apps.get_model("problem", "Problem")
|
||||
problems = Problem.objects.all()
|
||||
for problem in problems:
|
||||
test_case_dir = os.path.join(settings.TEST_CASE_DIR, problem.test_case_id)
|
||||
try:
|
||||
with open(os.path.join(test_case_dir, "info")) as f:
|
||||
info = json.load(f)
|
||||
if not info["spj"]:
|
||||
for id in info["test_cases"]:
|
||||
with open(os.path.join(test_case_dir,f"{id}.out"),"rb") as f:
|
||||
content = f.read()
|
||||
stripped_md5 = hashlib.md5(b"\n".join([x.rstrip() for x in content.split(b"\n") if len(x) > 0])).hexdigest()
|
||||
info["test_cases"][id]["all_stripped_output_md5"] = stripped_md5
|
||||
with open(os.path.join(test_case_dir, "info"), "w", encoding="utf-8") as f:
|
||||
f.write(json.dumps(info, indent=4))
|
||||
except Exception as err:
|
||||
print(f"{test_case_dir} info not found")
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('problem', '0012_auto_20180501_0436'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='problem',
|
||||
name='pe_ignored',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.RunPython(update_all_stripped_md5, reverse_code=migrations.RunPython.noop),
|
||||
]
|
||||
@ -54,6 +54,7 @@ class Problem(models.Model):
|
||||
languages = JSONField()
|
||||
template = JSONField()
|
||||
create_time = models.DateTimeField(auto_now_add=True)
|
||||
pe_ignored = models.BooleanField(default=False)
|
||||
# we can not use auto_now here
|
||||
last_update_time = models.DateTimeField(null=True)
|
||||
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||
|
||||
@ -65,6 +65,7 @@ class CreateOrEditProblemSerializer(serializers.Serializer):
|
||||
spj_code = serializers.CharField(allow_blank=True, allow_null=True)
|
||||
spj_compile_ok = serializers.BooleanField(default=False)
|
||||
visible = serializers.BooleanField()
|
||||
pe_ignored = serializers.BooleanField()
|
||||
difficulty = serializers.ChoiceField(choices=Difficulty.choices())
|
||||
tags = serializers.ListField(child=serializers.CharField(max_length=32), allow_empty=False)
|
||||
hint = serializers.CharField(allow_blank=True, allow_null=True)
|
||||
|
||||
@ -49,6 +49,7 @@ class TestCaseZipProcessor(object):
|
||||
|
||||
size_cache = {}
|
||||
md5_cache = {}
|
||||
stripped_md5_cache = {}
|
||||
|
||||
for item in test_case_list:
|
||||
with open(os.path.join(test_case_dir, item), "wb") as f:
|
||||
@ -56,6 +57,7 @@ class TestCaseZipProcessor(object):
|
||||
size_cache[item] = len(content)
|
||||
if item.endswith(".out"):
|
||||
md5_cache[item] = hashlib.md5(content.rstrip()).hexdigest()
|
||||
stripped_md5_cache[item] = hashlib.md5(b"\n".join([x.rstrip() for x in content.split(b"\n") if len(x) > 0])).hexdigest()
|
||||
f.write(content)
|
||||
test_case_info = {"spj": spj, "test_cases": {}}
|
||||
|
||||
@ -71,6 +73,7 @@ class TestCaseZipProcessor(object):
|
||||
test_case_list = zip(*[test_case_list[i::2] for i in range(2)])
|
||||
for index, item in enumerate(test_case_list):
|
||||
data = {"stripped_output_md5": md5_cache[item[1]],
|
||||
"all_stripped_output_md5": stripped_md5_cache[item[1]],
|
||||
"input_size": size_cache[item[0]],
|
||||
"output_size": size_cache[item[1]],
|
||||
"input_name": item[0],
|
||||
|
||||
@ -20,6 +20,7 @@ class JudgeStatus:
|
||||
PENDING = 6
|
||||
JUDGING = 7
|
||||
PARTIALLY_ACCEPTED = 8
|
||||
PRESNTATION_ERROR = 9
|
||||
|
||||
|
||||
class Submission(models.Model):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user