The NBA playoffs are heating up, and every game counts. As the postseason approaches, teams are fighting not only to secure a playoff spot, but also for favorable seeding that could determine their championship fate.
To determine their seeds, teams will be sorted by it's win percentage in descending order
Your task is to implement a ranking system that dynamically calculates the current standings of all participating teams based on their win-loss records and game results.
To reduce the range of data, we simulate only the Western Conference. The following images are all the Teams and their corresponding divisions.
Tie-Breaking Rules:
When comparing two or more teams that have the same win percentage, apply the following rules in order:
Definition: The cumulative difference between points scored and points allowed for each game
Teams with a higher point differential are ranked higher.
Points allowed in game = other team's score
(ex. Warriors Lakers 110 100. In Warriors' perspective, they allowed the Lakers to score 100 points in this game. In Lakers' perspective, they allowed the Warriors to score 110 points allowed in this game.)
Noted: Cumulative Point differential can be negative number
Definition: The win percentage in games played against teams from the same division.
Teams with a higher division win percentage can have a higher rank.
Retro-Rules
Before 2006, the first place of every division is guaranteed to be in the top 3 seeds, even though its win percentage may be lower than other teams.
For example,
Northwest | Win | Loss | Win percentage |
---|---|---|---|
Nuggets | 44 | 38 | 0.537 |
Jazz | 41 | 41 | 0.500 |
Thunder | 35 | 47 | 0.427 |
Pacific | Win | Loss | Win percentage |
---|---|---|---|
Suns | 54 | 28 | 0.659 |
Clippers | 47 | 35 | 0.573 |
Lakers | 45 | 37 | 0.549 |
Southwest | Win | Loss | Win percentage |
---|---|---|---|
Spurs | 63 | 19 | 0.768 |
Mavericks | 60 | 22 | 0.732 |
Grizzlies | 49 | 33 | 0.598 |
With the orginal rules, the ranking should be:
1. Spurs
2. Mavericks
3. Suns
4. Grizzlies
5. Clippers
6. Lakers
7. Nuggets
8. Jazz
9. Thunder
With the retro rules, the ranking will be:
1. Spurs (Leader of Southwest division)
2. Suns (Leader of Pacific division)
3. Nuggets (Leader of Northwest division)
4. Mavericks
5. Grizzlies
6. Clippers
7. Lakers
8. Jazz
9. Thunder
We will determine if using retro-rules or not at the end of input line using boolean expression.
Test cases
Header file explained
This problem is partial judge; we’ll provide partial header file:
Note (IMPORTANT: For preventing compiler error):
Line 1: Integer N (number of teams), G (number of games)
Next N lines: Each line contains information for one team:
<TeamName> <Division>
Next G lines: Each line contains one game result:
<TeamA> <TeamB> <ScoreA> <ScoreB>
Last line: Boolean expression which determines whether retro-rules is applied
Input parameter:
Ranked team names and its record, one team per line.
1. <TeamName> <wins>-<losses>
2. <TeamName> <wins>-<losses>
….
N. <TeamName> <wins>-<losses>
Noted: You shouldn't output the win percentage