Welcome To SDIBT ACM-ICPC Online Judge

VIRTUAL JUDGE Recent Contest F.A.Qs Discuss Home ProblemSet Status Ranklist 2 Contest LoginRegister Exam
Problem 1045. -- Football (aka Soccer)

Football (aka Soccer)

Time Limit: 1 Sec  Memory Limit: 64 MB
Submit: 5  Solved: 2
[Submit][Status][Discuss]

Description

Football is the most popular sport in the world, even through Americans insist on calling it ``soccer." A country such as five-time World Cup-winning Brazil has so many national and regional tournaments that is it very difficult to keep track. Your task is to write a program that receives the tournament name, team names, and games played and outputs the tournament standings so far. A team wins a game if it scores more goals than its opponent, and loses if it scores fewer goals. Both teams tie if they score the same number of goals. A team earns 3 points for each win, 1 point for each tie, and 0 points for each loss. Teams are ranked according to these rules (in this order): 1.Most points earned. 2.Most wins. 3.Most goal difference (i.e., goals scored - goals against) 4.Most goals scored. 5.Fewest games played. 6.Case-insensitive lexicographic order

Input

The first line of input will be an integer N in a line alone ( 0 < N < 1, 000). Then follow N tournament descriptions, each beginning with a tournament name. These names can be any combination of at most 100 letters, digits, spaces, etc., on a single line. The next line will contain a number T ( 1 < T30), which stands for the number of teams participating on this tournament. Then follow T lines, each containing one team name. Team names consist of at most 30 characters, and may contain any character with ASCII code greater than or equal to 32 (space), except for ``#'' and ``@'' characters. Following the team names, there will be a non-negative integer G on a single line which stands for the number of games already played on this tournament. G will be no greater than 1,000. G lines then follow with the results of games played in the format: team_name_1#goals1@goals2#team_name_2 For instance, Team A#3@1#Team B means that in a game between Team A and Team B, Team A scored 3 goals and Team B scored 1. All goals will be non-negative integers less than 20. You may assume that all team names mentioned in game results will have appeared in the team names section, and that no team will play against itself.

Output

For each tournament, you must output the tournament name in a single line. In the next T lines you must output the standings, according to the rules above. Should lexicographic order be needed as a tie-breaker, it must be done in a case-insensitive manner. The output format for each line is shown below: [a]) Team [b]p, [c]g ([d]-[e]-[f]), [g]gd ([h]-[i]) where [a] is team rank, [b] is the total points earned, [c] is the number of games played, [d] is wins, [e] is ties, [f] is losses, [g] is goal difference, [h] is goals scored, and [i] is goals against. There must be a single blank space between fields and a single blank line between output sets. See the sample output for examples.

Sample Input

2
World Cup 1998 - Group A
4
Brazil
Norway
Morocco
Scotland
6
Brazil#2@1#Scotland
Norway#2@2#Morocco
Scotland#1@1#Norway
Brazil#3@0#Morocco
Morocco#3@0#Scotland
Brazil#1@2#Norway
Some strange tournament
5
Team A
Team B
Team C
Team D
Team E
5
Team A#1@1#Team B
Team A#2@2#Team C
Team A#0@0#Team D
Team E#2@1#Team C
Team E#1@2#Team D

Sample Output

World Cup 1998 - Group A
1) Brazil 6p, 3g (2-0-1), 3gd (6-3)
2) Norway 5p, 3g (1-2-0), 1gd (5-4)
3) Morocco 4p, 3g (1-1-1), 0gd (5-5)
4) Scotland 1p, 3g (0-1-2), -4gd (2-6)

Some strange tournament
1) Team D 4p, 2g (1-1-0), 1gd (2-1)
2) Team E 3p, 2g (1-0-1), 0gd (3-3)
3) Team A 3p, 3g (0-3-0), 0gd (3-3)
4) Team B 1p, 1g (0-1-0), 0gd (1-1)
5) Team C 1p, 2g (0-1-1), -1gd (3-4)

HINT

Source

[Submit][Status][Discuss]

HOME Back

한국어 中文 English
All Copyright Reserved 2008-2010 SDIBT TEAM
GPL2.0 2003-2010 HUSTOJ Project TEAM
Anything about the Problems, Please Contact Admin:admin