Under construction

Still being built. Things may change

LTBL

Interview

Time limit2sMemory limit512 MB

Summary
Read match results between two teams, accumulate points, wins, draws, losses, and goals, then print the league table sorted by the six tiebreak rules.
Level

Medium4 of 10

Topics
Implementation, Sorting, Hash map, Simulation
Solved
No attempts yet

Problem

The Afghanistan League of Football has grown larger in the last few years. Ranking the teams in the league is a very important part of every league, and people want to understand what the current status of the league is. The league administration wants to create a website and publish the match result for public access. They need a program that can generate the data for the ranking table based on the match results. Write a program to help them with this problem.

Note:

  • A team wins if they score more goals than the other team
  • A match is a draw if both teams score the same number of goals
  • A team will receive 3 points for each win, 1 for each draw, and a 0 for each loss
  • Sort the table based on points (higher first), number of wins (higher first), number of draw (higher first), number of loss (lower first), number of scored goals (higher first), and number of received goals (lower first)
  • To teams can play multiple times with each other.
  • Some teams may play more games than other teams, e.g.: in the left every team played 4 games. And in the right with the same number of teams, each played different numbers of games.

Input

First line contains the number of test cases (T): 0 < T < 1000

Next line contains the number of matches (M): 0 < M <= 256

Each next line contains the match result between two teams in this format:

  • team1 [team1_goals_count - team2_goals_count] team2 0 < len(team[1 and 2]) < 100, 0 <= team[1 and 2]_goals_count < 20
  • E.g.: Shahin [2 - 2] Hariwa

Output

Print the league table for each test case in the following format:

  • team-name,points,wins,draw,loss,goals-scored,goals-received E.g.: Shahin,12,3,0,0,10,2

Separate each test case output with an empty line (no empty line after the last testcase result).

Hint

Examples1

  1. Example 1

    Input
    1
    6
    team1 [2 - 0] team3
    team1 [1 - 1] team2
    team2 [4 - 7] team3
    team2 [0 - 0] team1
    team3 [5 - 3] team1
    team3 [6 - 1] team2
    
    Expected output
    team1,5,1,2,1,6,6
    team2,2,0,2,2,6,14
    team3,9,3,0,1,18,10