NDOJ/judge/tasks/experiment.py

22 lines
594 B
Python
Raw Normal View History

2021-07-28 22:58:42 +00:00
from judge.models import SubmissionTestCase, Problem
2020-12-01 23:18:17 +00:00
2021-01-29 04:43:10 +00:00
from collections import defaultdict
2020-12-01 23:18:17 +00:00
2022-05-14 17:57:27 +00:00
2020-12-01 23:18:17 +00:00
def generate_report(problem):
testcases = SubmissionTestCase.objects.filter(submission__problem=problem).all()
2022-05-14 17:57:27 +00:00
2020-12-01 23:18:17 +00:00
score = defaultdict(int)
total = defaultdict(int)
rate = defaultdict(int)
for case in testcases.iterator():
2022-05-14 17:57:27 +00:00
score[case.case] += int(case.status == "AC")
2020-12-01 23:18:17 +00:00
total[case.case] += 1
for i in score:
rate[i] = score[i] / total[i]
for i, _ in sorted(rate.items(), key=lambda x: x[1], reverse=True):
2022-05-14 17:57:27 +00:00
print(i, score[i], total[i], rate[i])