Skip to content

Commit 55055f4

Browse files
committed
scoreboard: respect opt-score as tiebreaker in row ordering
Add opt-score comparison to Scoreboard::scoreCompare(). When ‘Use optimisation score as score-tiebreaker’ is enabled, the list is now sorted by: 1. points 2. totalOptScore (max or min, per contest setting) 3. total runtime / total time 4. solve-times sequence Fixes the discrepancy where the UI still ranked teams by first-AC time even though opt-score decided the official rank. Supports both “maximize” (desc) and “minimize” (asc) modes.
1 parent 34c8bb2 commit 55055f4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

webapp/src/Utils/Scoreboard/Scoreboard.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,14 @@ protected function scoreCompare(TeamScore $a, TeamScore $b): int
292292
if ($a->totalRuntime != $b->totalRuntime) {
293293
return $a->totalRuntime <=> $b->totalRuntime;
294294
}
295+
} else if ($this->getOptscoreAsScoreTiebreaker()) {
296+
if ($a->totalRuntime != $b->totalRuntime) {
297+
if ($this->getOptScoreOrder() === "asc") {
298+
return $a->totalOptscore <=> $b->totalOptscore;
299+
} else {
300+
return $b->totalOptscore <=> $a->totalOptscore;
301+
}
302+
}
295303
} else { // solvetime ordering
296304
if ($a->totalTime != $b->totalTime) {
297305
return $a->totalTime <=> $b->totalTime;
@@ -469,4 +477,13 @@ public function getOptScoreAsScoreTiebreaker(): bool
469477
{
470478
return $this->contest->getOptScoreAsScoreTiebreaker();
471479
}
480+
481+
/**
482+
* Determine order by optscore
483+
* @return string
484+
*/
485+
public function getOptScoreOrder(): string
486+
{
487+
return $this->contest->getOptScoreOrder();
488+
}
472489
}

0 commit comments

Comments
 (0)