Football (aka Soccer)

2020年1月17日 922点热度 0人点赞 0条评论

Football (aka Soccer)

时间: 1ms        内存:64M

描述:

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

输入:

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.

输出:

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.

示例输入:

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

示例输出:

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)

提示:

参考答案:

解锁文章

没有看到答案?微信扫描二维码可免费解锁文章

微信扫描二维码解锁

使用微信扫描二维码打开广告页面后可以立即关闭,再刷新此页面即可正常浏览此文章

所跳转广告均由第三方提供,并不代表本站观点!

已经扫描此二维码?点此立即跳转

code

这个人很懒,什么都没留下

文章评论