编程介的小学生 2017-09-02 12:27 采纳率: 20.5%
浏览 623
已采纳

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

  • 写回答

1条回答

  • 战在春秋 2017-09-04 21:32
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab生成电测深三层曲线模型代码
  • ¥50 随机森林与房贷信用风险模型
  • ¥50 buildozer打包kivy app失败
  • ¥30 在vs2022里运行python代码
  • ¥15 不同尺寸货物如何寻找合适的包装箱型谱
  • ¥15 求解 yolo算法问题
  • ¥15 虚拟机打包apk出现错误
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 三菱伺服电机按启动按钮有使能但不动作