Premier League Table

면접 대비

시간 제한2초메모리 제한2048 MB

요약
경기 결과를 읽어 각 팀의 전적과 승점을 집계한 뒤 승점, 골득실, 이름 순으로 정렬한다.
난이도

쉬움10점 중 3점

유형
해시맵, 정렬, 구현
정답자
아직 제출이 없습니다

문제

The Premier League is the highest level of football (soccer, if you must!) in England and is widely considered the best football league in the world. Most football leagues around the world, including the Premier League, use a point system to determine who wins the league trophy.

Each team receives 33 points for winning a game, 11 point for drawing (tie), and 00 for losing. After 3838 games (also called "fixtures") in a season spanning from August to May, the winner of the league is the team with the most points.

However, if points are tied, it goes to whichever team has the best goal differential (GD) calculated by taking the goals scored (called GF, goals for) minus goals let in (called GA, goals against). Note that goal differential can be a negative number. If neither points nor GD can break the tie, the teams are sorted alphabetically.1

The Premier League needs your help! The company they hired couldn't figure out how to make the table, so they hired you to create a sorted Premier League table based off of the results of all matches from a season.


1No, they don't use this as the actual tie-breaker

입력

The first line of input will be NN, the number of fixtures to follow. The next NN lines will be the scores of each fixture throughout a season in the following format:

Team_One X-Y Team_Two

where Team_One is the first team and X is their score for that fixture and Team_Two is the second team and Y is their score for that fixture. Both X and Y are guaranteed to be non-negative numbers.

Input Restrictions

  • Team names will only have upper- and lower-case letters or underscores. No team names will have any whitespace.
  • The minimum amount of goals scored by either team is 00, while the maximum is 1,000,0001\\,000\\,000.2
  • The minimum number of unique teams given is 22, while the maximum is 2020 unique teams.
  • While a traditional season has 3838 games, the number of games provided in the inputs can be anywhere from 11 to 10,00010\\,000.

2Yes, a million goals scored in one game is physically impossible.

출력

The output is a sorted league table with each line representing data from a single team. The data on each line should be space-separated, and should be as follows:

Team name, how many games the team has played (MP), number of wins, number of draws, number of losses, goals for (GF), goals against (GA), goal differential (GD), and points (PTS).

Each team is uniquely identified by their name in the input; there will be no duplicate team names.

Sorting priority (from highest to lowest) is points →\rightarrow GD →\rightarrow alphabetical. For instance, if two teams both have 7070 points, then the team with the higher GD will appear earlier in the table. If two teams have both the same number of points and the same GD, then the team whose name comes first alphabetically will appear earlier in the table.

예제2

  1. 예제 1

    입력
    2
    Manchester_City 1-3 Liverpool
    Leicester_City 2-1 Manchester_United
    
    예상 출력
    Liverpool 1 1 0 0 3 1 2 3
    Leicester_City 1 1 0 0 2 1 1 3
    Manchester_United 1 0 0 1 1 2 -1 0
    Manchester_City 1 0 0 1 1 3 -2 0
    
  2. 예제 2

    입력
    4
    Watford 4-1 Wolves
    Aston_Villa 3-1 Burnley
    Watford 4-2 Leeds_United
    Crystal_Palace 2-4 Aston_Villa
    
    예상 출력
    Watford 2 2 0 0 8 3 5 6
    Aston_Villa 2 2 0 0 7 3 4 6
    Burnley 1 0 0 1 1 3 -2 0
    Crystal_Palace 1 0 0 1 2 4 -2 0
    Leeds_United 1 0 0 1 2 4 -2 0
    Wolves 1 0 0 1 1 4 -3 0