Under construction

Still being built. Things may change

Super 12

Time limit1sMemory limit128 MB

Summary
Simulate a rugby league by computing bonus points, sorting standings after every full round, and printing formatted tables.
Level

Medium5 of 10

Topics
Simulation, Sorting, Implementation
Solved
No attempts yet

Problem

In a rugby league, the standings are meaningful at the end of each round because every team has then played the same number of games.

For each game, a team receives 4 points for a win, 2 points for a draw, and 0 points for a loss. A team that scores at least 4 tries in a game receives 1 bonus point. A team that loses by fewer than 8 points also receives 1 bonus point.

At the end of each round, print the league table after sorting the teams by these rules:

  • Higher league points come first.
  • If league points are equal, the larger spread, defined as cumulative points scored minus cumulative points conceded, comes first.
  • If still equal, the larger cumulative number of tries scored comes first.
  • If still equal, the lexicographically smaller team name comes first.

No two teams remain tied after all of these rules are applied.

Input

The input describes the results of one league.

First, the competing team names are given, one per line. There are at most 20 teams, the number of teams is always even, and each name has at most 20 characters. The team list ends with a line containing #.

The game results follow, one per line, and also end with a line containing #. Each result gives the home team name, the away team name, the home score, the away score, the number of tries by the home team, and the number of tries by the away team, in that order.

There is no separate marker for the end of a round. If there are N teams, one round contains N / 2 games, at which point every team has played exactly once.

Output

After each round, output the league table.

The first line of a table is Round, a space, and the round number starting from 1. Then output the teams in standing order, one per line.

Each team line contains the team name, followed from column 22 by these right-aligned values: league points in width 2, cumulative score in width 4, cumulative score conceded in width 4, cumulative tries scored in width 3, and cumulative tries conceded in width 3.

Output one blank line between consecutive round tables.

Examples1

  1. Example 1

    Input
    Highlanders
    Crusaders
    Warriors
    ThisIsTheLongestName
    #
    Highlanders Crusaders 25 24 3 2
    Warriors ThisIsTheLongestName 32 16 5 1
    ThisIsTheLongestName Highlanders 10 20 1 2
    Crusaders Warriors 17 16 3 3
    #
    
    Expected output
    Round 1
    Warriors              5  32  16  5  1
    Highlanders           4  25  24  3  2
    Crusaders             1  24  25  2  3
    ThisIsTheLongestName  0  16  32  1  5
    
    Round 2
    Highlanders           8  45  34  5  3
    Warriors              6  48  33  8  4
    Crusaders             5  41  41  5  6
    ThisIsTheLongestName  0  26  52  2  7