Football the most popular sport in the world (americans insist to call it “Soccer”, but we will call it “Football”). As everyone knows, Brasil is the country that have most World Cup titles (four of them: 1958, 1962, 1970 and 1994). As our national tournament have many teams (and even regional tournaments have many teams also) it’s a very hard task to keep track of standings with so many teams and games played!
    So, your task is quite simple: 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 oponent. Obviously, a team loses a game if it scores less goals. hen both teams score the same number of goals, we call it a tie. A team earns 3 points for each win, 1 point for each tie and 0 point 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. Less games played.
  6. Lexicographic order.

Input
The first line of input will be an integer N in a line alone (0 < N < 1000). Then, will follow N tournament descriptions. Each one begins with the tournament name, on a single line. Tournament names can have any letter, digits, spaces etc. Tournament names will have length of at most 100. Then, in the next line, there will be a number T (1 < T ≤ 30), which stands for the number of teams participating on this tournament. Then will follow T lines, each one containing one team name. Team names may have any character that have ASCII code greater than or equal to 32 (space), except for ‘#’ and ‘@’ characters, which will never appear in team names. No team name will have more than 30 characters.
    Following to 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 1000. Then, G lines will follow with the results of games played. They will follow this format:
team name 1#goals1@goals2#team name 2
    For instance, the following line:
Team A#3@1#Team B
    Means that in a game between T eam A and T eam B, T eam A scored 3 goals and T eam B scored 1.
    All goals will be non-negative integers less than 20. You may assume that there will not be inexistent team names (i.e. all team names that appear on game results will have apperead on 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. Notice that should the tie-breaker be the lexographic order, it must be done case insenstive. The output format for each line is shown bellow:
[a]) T eam name [b]p, [c]g ([d]-[e]-[f]), [g]gd ([h]-[i])
Where:
• [a] = team rank
• [b] = total points earned
• [c] = games played
• [d] = wins
• [e] = ties
• [f] = losses
• [g] = goal difference
• [h] = goals scored
• [i] = 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)

问题链接:UVA10194 Football (aka Soccer)
问题简述:(略)
问题分析
    繁琐的排序题,不解释。
程序说明
    程序中,函数scanf()按正则表达式格式输入,函数strcasecmp()忽略大小写的比较。这两个用法值得推荐,可以大幅简化代码。
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10194 Football (aka Soccer) */#include <bits/stdc++.h>using namespace std;const int N = 100;
const int TN = 32;
const int T = 30;
struct Team {char name[TN + 1];      // 球队名字int point;      // 得分int wins;       // 胜场数int ties;       // 平场数int losses;     // 输场数int scored;     // 进球int against;        // 失球
};int cmp(const Team& a, const Team& b){if(a.point != b.point)      // 得分高的先输出return a.point > b.point;if(a.wins != b.wins)        // 胜场数高的先输出return a.wins > b.wins;if((a.scored - a.against) != (b.scored - b.against))        // 净进球数高的先输出return (a.scored - a.against) > (b.scored - b.against);if(a.scored != b.scored)        // 进球数高的先输出return a.scored > b.scored;if((a.wins + a.ties + a.losses) != (b.wins + b.ties + b.losses))       // 参与场次少的先输出return (a.wins + a.ties + a.losses) < (b.wins + b.ties + b.losses);return strcasecmp(a.name, b.name) < 0;     // 队名字典序输出
}int main()
{int n, t, g;char name[N + 1];scanf("%d", &n);getchar();while(n--) {Team team[T];gets(name);scanf("%d", &t);getchar();memset(team, 0, sizeof(team[0]) * t);for(int i = 0; i < t; i++)gets(team[i].name);scanf("%d", &g);getchar();char team1[TN + 1], team2[TN + 1];int g1, g2, t1 = 0, t2 = 0;for(int i = 0; i < g; i++) {scanf("%[^#]#%d@%d#%[^\n]", team1, &g1, &g2, team2);getchar();for(int j = 0; j < t; j++) {if(strcmp(team1, team[j].name) == 0)t1 = j;if(strcmp(team2, team[j].name) == 0)t2 = j;}team[t1].scored += g1;team[t1].against += g2;team[t2].scored += g2;team[t2].against += g1;if (g1 > g2) {team[t1].point += 3;team[t1].wins++;team[t2].losses++;} else if (g1 == g2) {team[t1].point += 1;team[t1].ties++;team[t2].point += 1;team[t2].ties++;} else if (g1 < g2) {team[t1].losses++;team[t2].point += 3;team[t2].wins++;}}sort(team, team + t, cmp);printf("%s\n", name);for(int i = 0; i < t; i++) {printf("%d) ", i + 1);printf("%s ", team[i].name);printf("%dp, ", team[i].point);printf("%dg ", (team[i].wins + team[i].ties + team[i].losses));printf("(%d-%d-%d), ", team[i].wins, team[i].ties, team[i].losses);printf("%dgd ", (team[i].scored - team[i].against));printf("(%d-%d)\n", team[i].scored, team[i].against);}if(n) printf("\n");}return 0;
}

UVA10194 Football (aka Soccer)【排序】相关推荐

  1. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  2. Competitive Programming专题题解(1)

    Competitive Programming题解 AOAPC I: Beginning Algorithm Contests 题解 CP2-1.1.1 Easy(Ad Hoc Problems) P ...

  3. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  4. ICPC程序设计题解书籍系列之八:(美)斯基纳等:《挑战编程-程序设计竞赛训练手册》

    S书<挑战编程--程序设计竞赛训练手册>题目一览 1 Getting Started UVA100 POJ1207 HDU1032 The 3n + 1 problem[水题] - 海岛B ...

  5. (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  6. UVa Online Judge 工具網站

    UVa Online Judge 工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.html Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 M ...

  7. 算法竞赛入门经典+挑战编程+USACO

    下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...

  8. ACMer Training 学习指导

    本文原地址 一.UVaOJ http://uva.onlinejudge.org 西班牙Valladolid大学的程序在线评测系统,是历史最悠久.最著名的OJ. 二.<算法竞赛入门经典> ...

  9. 提取了下刘汝佳推荐的题号...

    今天闲来没事上uva oj提取了下刘汝佳推荐的acm题号,原始数据如下: Volume 0. Getting Started    10055 - Hashmat the Brave Warrior ...

最新文章

  1. NDK交叉编译及so库导入Android项目
  2. redis 4.0.8 源码包安装集群
  3. 如何测试java支持的最大内存
  4. Docker容器的迁移
  5. vba执行linux命令,如何使用vba的shell()运行参数的.exe?
  6. 【工具】Notepad++的一些常用配置
  7. 搜狗浏览器下 禁止浏览器自动填写用户名、密码
  8. 为什么要在JavaScript中使用静态类型? 我们是否应该使用它们?
  9. 面试招聘——操作系统专场(一)
  10. 期货市场技术分析02_趋势的基本概念
  11. Linux系统下poll的使用方式
  12. 【javascript笔记】关于javascript中的闭包
  13. 【Flash动画制作】
  14. 十款最好用的远程桌面工具
  15. java 随机生成姓名_生成随机中文姓名java程序.pdf
  16. 再见了,收费的XShell,我改用国产良心工具!
  17. 自己来控制EntityFramework4.1 Code-First,逐步消除EF之怪异现象
  18. 联想服务器rd640性能,至强E5芯动力 联想RD640服务器评测
  19. Mac剪切AVI视频
  20. Toefl-Speaking

热门文章

  1. 记录一次游戏服务器的压测调优记录(Golang语言)
  2. DirectX9 ShadowMap例子学习笔记
  3. Javascript中常用的经典技巧
  4. 5.3 同步操作和强制排序
  5. Spark的三种运行模式
  6. hive 外部表不支持添加列
  7. 详解:Hive中的NULL的处理、优点、使用情况(注意)
  8. 下面是java语言的关键字是_下面4个选项中,哪个是Java语言的关键字:
  9. 带sex的net域名_sex.com(性)域名争夺再升级 色情能抵千万美金?
  10. ediplus 复制编辑一列_Excel中如何使用公式查找一列中的重复值并且在另一列里面列出来...