cho.sh
Notes
Loading...

Super 12

Time limit

1s

Memory limit

128 MB

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.