编程介的小学生 2017-03-22 08:10 采纳率: 20.5%
浏览 691
已采纳

Football Match

Today football has become the most popular sport all over the world. Many countries have their own football league matches. And the FIFA wants to hold a great league match which could contains all the clubs throughout the world. It is difficult to rank so many teams just by hand. So they come to you for help.

The rules of ranking are:
1. A team will get 3 points when they win a match, 1 point when get a draw, 0 point when lost.
2. Teams are ranked by their total points first. If two teams have the same points, the team who get the more "goal difference" ranks higher. "Goal difference" for a team is equal to the total number of balls they goal minus those they lost.
3. If two teams have both the same points and the same "goal difference", ranking them by their name alphabetically.

Input

The input contains many cases. The beginning of each case is a num m (m<=10000), which is the number of matches. The following m lines each give a score of a match. The format is:
Team_name1 score1:score2 Team_name2
The length of team name is no more than 20 characters and the scores are less than 100. You may assume that every team in the league has taken part in at least one match.

Output

For each case output a ranking table, each team a line. The format of each line is
Id Nm w d l Pt Gd
"Id" is the index of the team starting from 1. "Nm" is the name of the team. "w", "d" and "l" respectively is the total number of matches the team win, draw and lost. "Pt" is the points of the team. And "Gd" is the team's goal difference.
Use a single blank to separate all cases.

Sample Input
4
Liverpool 1:0 ManchesterU
ManchesterU 3:0 Leeds
Arsenal 2:2 Liverpool
Leeds 1:5 Arsenal
6
RealMadrid 3:2 ACMilan
ZJGreenCity 3:2 RealMadrid
ACMilan 1:4 ZJGreenCity
RealMadrid 0:0 ZJGreenCity
ACMilan 2:0 RealMadrid
ZJGreenCity 3:3 ACMilan
Sample Output
1 Arsenal 1 1 0 4 4
2 Liverpool 1 1 0 4 1
3 ManchesterU 1 0 1 3 2
4 Leeds 0 0 2 0 -7

1 ZJGreenCity 2 2 0 8 4
2 ACMilan 1 1 2 4 -2
3 RealMadrid 1 1 2 4 -2

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-03-22 17:24
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看