14643 - NBA Playoffs Ranking Simulator   

Description

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.

 

  • Each team will be provided with basic identity information (teamName and division), and you will also be given a sequence of games, each consisting of two competing teams and their respective scores.

  • As games are processed, your program must update each team’s overall record, point differential, and division-specific statistics. Once all games have been processed, you must compute and output the final team rankings based on a simplified version of the official NBA tie-breaking rules.

 

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:

  1. Cumulative Point differential (+/-)

    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

  1. Division win percentage

               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

  • Testcase 1, 2: No tie-breaking scenario
  • Testcase 3, 4: With tie-breaking scenario
  • Testcase 5: Retro-Rules applied

 

Header file explained

This problem is partial judge; we’ll provide partial header file:

Note (IMPORTANT: For preventing compiler error):

  • While implementing, remember to #include "function.h", and type the function within your main.cpp
  • You should implement main function in your submit code. If you upload the modified partial judge code, please remove #ifdef LOCAL_TEST , #endif
  • nameToId & divisionLeaders should be redefine in your main.cpp if you want to use it.
  • All the functions in header file is optional, you don't need to implement all, and you can modify the function parameter if you want.
  • While implementing function compare, remember to handle floating-point precision with EPS = 1e-8

Input

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:

  • TeamName, TeamA, TeamB, and Division are strings without spaces.
  • Division will be either Northwest, Pacific, or Southwest
  • Team names will be shortened to their commonly known identifiers without spaces (e.g., “Dallas Mavericks” becomes “Mavericks”; “Portland Trail Blazers” becomes “TrailBlazers”).
  • 0 <= ScoreA, ScoreB <= 150
  • Boolean expression contains only lowercase letters

Output

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

Sample Input  Download

Sample Output  Download

Partial Judge Code

14643.cpp

Partial Judge Header

14643.h


Discuss