Add frozen subtasks
This commit is contained in:
parent
bdd30f94b7
commit
6bd5bb290f
13 changed files with 117 additions and 34 deletions
|
@ -98,15 +98,22 @@ class BaseContestFormat(metaclass=ABCMeta):
|
|||
return "partial-score"
|
||||
|
||||
def handle_frozen_state(self, participation, format_data):
|
||||
if not self.contest.freeze_after:
|
||||
return
|
||||
frozen_subtasks = {}
|
||||
if hasattr(self, "get_frozen_subtasks"):
|
||||
frozen_subtasks = self.get_frozen_subtasks()
|
||||
|
||||
queryset = participation.submissions.values("problem_id").annotate(
|
||||
time=Max("submission__date")
|
||||
)
|
||||
for result in queryset:
|
||||
problem = str(result["problem_id"])
|
||||
if format_data.get(problem):
|
||||
if result["time"] >= self.contest.freeze_after + participation.start:
|
||||
is_after_freeze = (
|
||||
self.contest.freeze_after
|
||||
and result["time"]
|
||||
>= self.contest.freeze_after + participation.start
|
||||
)
|
||||
if is_after_freeze or frozen_subtasks.get(problem):
|
||||
format_data[problem]["frozen"] = True
|
||||
else:
|
||||
format_data[problem] = {"time": 0, "points": 0, "frozen": True}
|
||||
|
|
|
@ -111,7 +111,9 @@ class IOIContestFormat(DefaultContestFormat):
|
|||
contest_problem.problem.code,
|
||||
],
|
||||
),
|
||||
points=floatformat(format_data["points"]),
|
||||
points=floatformat(
|
||||
format_data["points"], -self.contest.points_precision
|
||||
),
|
||||
time=nice_repr(timedelta(seconds=format_data["time"]), "noday")
|
||||
if self.config["cumtime"]
|
||||
else "",
|
||||
|
@ -122,7 +124,7 @@ class IOIContestFormat(DefaultContestFormat):
|
|||
def display_participation_result(self, participation):
|
||||
return format_html(
|
||||
'<td class="user-points">{points}<div class="solving-time">{cumtime}</div></td>',
|
||||
points=floatformat(participation.score),
|
||||
points=floatformat(participation.score, -self.contest.points_precision),
|
||||
cumtime=nice_repr(timedelta(seconds=participation.cumtime), "noday")
|
||||
if self.config["cumtime"]
|
||||
else "",
|
||||
|
|
|
@ -14,6 +14,21 @@ class NewIOIContestFormat(IOIContestFormat):
|
|||
cumtime: Specify True if time penalties are to be computed. Defaults to False.
|
||||
"""
|
||||
|
||||
def get_frozen_subtasks(self):
|
||||
queryset = self.contest.contest_problems.values_list("id", "frozen_subtasks")
|
||||
res = {}
|
||||
for problem_id, frozen_subtasks in queryset:
|
||||
subtasks = set()
|
||||
if frozen_subtasks:
|
||||
frozen_subtasks = frozen_subtasks.split(",")
|
||||
for i in frozen_subtasks:
|
||||
try:
|
||||
subtasks.add(int(i))
|
||||
except Exception as e:
|
||||
pass
|
||||
res[str(problem_id)] = subtasks
|
||||
return res
|
||||
|
||||
def get_results_by_subtask(self, participation, include_frozen=False):
|
||||
frozen_time = self.contest.end_time
|
||||
if self.contest.freeze_after and not include_frozen:
|
||||
|
@ -65,6 +80,7 @@ class NewIOIContestFormat(IOIContestFormat):
|
|||
ON (sub.id = cs.submission_id AND sub.status = 'D')
|
||||
INNER JOIN judge_submissiontestcase tc
|
||||
ON sub.id = tc.submission_id
|
||||
WHERE sub.date < %s
|
||||
GROUP BY cp.id, tc.batch, sub.id
|
||||
) r
|
||||
GROUP BY prob, batch
|
||||
|
@ -73,7 +89,12 @@ class NewIOIContestFormat(IOIContestFormat):
|
|||
WHERE p.max_batch_points = q.batch_points
|
||||
GROUP BY q.prob, q.batch
|
||||
""",
|
||||
(participation.id, to_database_time(frozen_time), participation.id),
|
||||
(
|
||||
participation.id,
|
||||
to_database_time(frozen_time),
|
||||
participation.id,
|
||||
to_database_time(frozen_time),
|
||||
),
|
||||
)
|
||||
|
||||
return cursor.fetchall()
|
||||
|
@ -82,6 +103,7 @@ class NewIOIContestFormat(IOIContestFormat):
|
|||
cumtime = 0
|
||||
score = 0
|
||||
format_data = {}
|
||||
frozen_subtasks = self.get_frozen_subtasks()
|
||||
|
||||
for (
|
||||
problem_id,
|
||||
|
@ -101,10 +123,11 @@ class NewIOIContestFormat(IOIContestFormat):
|
|||
|
||||
if format_data.get(problem_id) is None:
|
||||
format_data[problem_id] = {"points": 0, "time": 0, "total_points": 0}
|
||||
format_data[problem_id]["points"] += subtask_points
|
||||
if subtask not in frozen_subtasks.get(problem_id, set()):
|
||||
format_data[problem_id]["points"] += subtask_points
|
||||
format_data[problem_id]["total_points"] += total_subtask_points
|
||||
format_data[problem_id]["time"] = max(dt, format_data[problem_id]["time"])
|
||||
format_data[problem_id]["problem_points"] = problem_points
|
||||
format_data[problem_id]["total_points"] += total_subtask_points
|
||||
|
||||
for problem_data in format_data.values():
|
||||
if not problem_data["total_points"]:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue