Contest Scoreboard
Time Limit: 2 Seconds Memory Limit: 65536 KB

Think the contest score boards are wrong? Here’s your chance to come up with the right rankings.
Contestants are ranked first by the number of problems solved (the more the better), then by decreasing amounts of penalty time. If two or more contestants are tied in both problems solved and penalty time, they are displayed in order of increasing team numbers.

A problem is considered solved by a contestant if any of the submissions for that problem was judged correct. Penalty time is computed as the number of minutes it took for the first correct submission for a problem to be received plus 20 minutes for each incorrect submission received prior to the correct solution. Unsolved problems incur no time penalties.

Input

Input consists of a snapshot of the judging queue, containing entries from some or all of contestants 1 through 100 solving problems 1 through 9. Each line of input will consist of three numbers and a letter in the format

contestant problem time L

where L can be C, I, R, U or E. These stand for Correct, Incorrect, clarification Request, Unjudged and Erroneous submission. The last three cases do not affect scoring.

Lines of input are in the order in which submissions were received.

Subsequent test cases are separated with a single blank line.

Output

Output will consist of a scoreboard sorted as previously described. Each line of output will contain a contestant number, the number of problems solved by the contestant and the time penalty accumulated by the contestant. Since not all of contestants 1-100 are actually participating, display only the contestants that have made a submission.

Separate output for different cases with a single blank line.

Sample Input

1 2 10 I
3 1 11 C
1 2 19 R
1 2 21 C
1 1 25 C

Sample Output

1 2 66
3 1 11

Source: University of Waterloo Local Contest 1998.06.06

问题链接:UVA10258 Contest Scoreboard
问题简述:(略)
问题分析
    ACM比赛得分滚动榜问题。简单题,需要用到排序算法函数sort()。
    需要注意输入输出格式以及空行的处理。
程序说明:(略)
参考链接:(略)
题记:输入输出格式需要了然于心!

AC的C++语言程序(UVA)如下:

/* UVA10258 Contest Scoreboard */#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>using namespace std;const int N = 100;
const int P = 9;int status[N + 1][P + 1];
int tindex[N + 1];
struct Record {int team, cnt, time;
} record[N + 1];bool cmp( Record a, Record b )
{return a.cnt != b.cnt ? a.cnt > b.cnt : (a.time != b.time ? a.time < b.time : a.team < b.team);
}char buf[128];int main()
{int t;scanf("%d",&t);getchar();for(int i = 1; i <= t; i++) {memset(record, 0, sizeof(record));memset(status,0,sizeof(status));memset(tindex, -1, sizeof(tindex));int cnt=0, team, problem, time;char L;if(i == 1)getchar();while(gets(buf) != NULL && buf[0]) {sscanf(buf, "%d %d %d %c", &team, &problem, &time, &L);if(tindex[team] == -1) {tindex[team] = cnt;cnt++;}int k = tindex[team];record[k].team = team;if(status[k][problem] != -1) {      // 已经AC的题不再处理if(L == 'C') {record[k].time +=  status[k][problem] * 20 + time;record[k].cnt++;status[k][problem] = -1;} else if(L == 'I')status[k][problem]++;      // 未AC次数统计}}sort(record, record + cnt, cmp);for(int j=0; j<cnt; j++)printf("%d %d %d\n", record[j].team, record[j].cnt, record[j].time);if(i != t) printf("\n");}return 0;
}

AC的C++语言程序(ZOJ)如下:

/* ZOJ1837 Contest Scoreboard */#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>using namespace std;const int N = 100;
const int P = 9;int status[N + 1][P + 1];
int tindex[N + 1];
struct Record {int team, cnt, time;
} record[N + 1];bool cmp( Record a, Record b )
{return a.cnt != b.cnt ? a.cnt > b.cnt : (a.time != b.time ? a.time < b.time : a.team < b.team);
}char buf[128];int main()
{int caseno = 0;char *ret;do {memset(record, 0, sizeof(record));memset(status,0,sizeof(status));memset(tindex, -1, sizeof(tindex));int cnt=0, team, problem, time;char L;while((ret = gets(buf)) != NULL && buf[0]) {sscanf(buf, "%d %d %d %c", &team, &problem, &time, &L);if(tindex[team] == -1) {tindex[team] = cnt;cnt++;}int k = tindex[team];record[k].team = team;if(status[k][problem] != -1) {      // 已经AC的题不再处理if(L == 'C') {record[k].time +=  status[k][problem] * 20 + time;record[k].cnt++;status[k][problem] = -1;} else if(L == 'I')status[k][problem]++;      // 未AC次数统计}}if(cnt > 0) {if(++caseno > 1)printf("\n");sort(record, record + cnt, cmp);for(int i=0; i<cnt; i++)printf("%d %d %d\n", record[i].team, record[i].cnt, record[i].time);}} while(ret != NULL);return 0;
}

UVA10258 ZOJ1837 Contest Scoreboard【结构排序】相关推荐

  1. SQL SERVER树状结构排序

    1 1.1 1.2 2 2.1 2.1.1 2.1.2 2.2 2.2.1 假如我们查询到树状结构数据,并要求对其排序,排序效果如上图.实现的思路如下:对每一层的节点按照排序字段排序,同一层节点按照排 ...

  2. c语言循环结构排序,C语言循环结构 -C语言冒泡排序算法(附带源码)

    排序(sorting)就是调整列表的顺序,是计算机编程中经常要做的一件事情.经过排序以后的数据,可以极大地提高查找的效率. 冒泡排序(bubble sort)是用嵌套的 for 循环来实现的,其名称来 ...

  3. python结构排序_Python数据结构(七)排序算法 上

    Python数据结构(七)排序算法 上 上回: 本文的重点不是代码,而是带着大家分析每一个排序算法背后的思想以及使用到的数据结构.很多时候不是我们想不出算法该如何去写,而是题目并没有指定特定的数据结构 ...

  4. mysql 父子结构排序_mysql 父子结构排序 | 学步园

    项目中经常会遇到父子结构显示的问题,不同的数据库有不同的写的方式,比如SqlServer中用with union 实现,而Mysql则没有这么方便的语句. 如下category表,食品有pizaa,b ...

  5. UVa 10258 - Contest Scoreboard

    题目大意:关于acm竞赛排名的题目,对于参赛者首先按做出的题目排名,然后是罚时,最后是编号. 多关键字域排序问题. 1 #include <cstdio> 2 #include <c ...

  6. Competitive Programming 3题解

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

  7. Competitive Programming专题题解(1)

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

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

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

  9. 在python中排序元组

    在Python中,当你排序一个元组时,如下所示: >>> items = [(1, 'B'), (1, 'A'), (2, 'A'), (0, 'B'), (0, 'a')] > ...

最新文章

  1. 数据结构一:链表(循环链表)
  2. [LintCode笔记了解一下]64.合并排序数组
  3. gm怎么刷东西 rust_Rust语言:解引用详述,搞不明白这个概念,趁早放弃Rust
  4. 蚂蚁集团高级架构师郭援非:分布式数据库是金融机构数字化转型的最佳路径...
  5. Codeforces D - High Load
  6. Oracle Real Application Testing diagram
  7. 计算机应用缺什么人才,中国缺少什么专业人才
  8. Matlab-中寻找峰值函数,波峰波谷
  9. Makefile编写练习题
  10. 浅谈搜索引擎排序2020-09-04
  11. 微信小程序名片3:0大战纸质名片,你应该知道如何选择了吧
  12. libreCAD源码阅读笔记3
  13. 区块链app商城软件系统开发浅析
  14. system mysql服务
  15. 大数据周会-本周学习内容总结06
  16. 接招吧微软,谷歌大脑跟DeepMind团队合并了!
  17. Python编程:从入门到实践第六章读书笔记6.3遍历字典
  18. 流的操作(二)如何选择流?
  19. 简洁rtmp源站服务器
  20. c++关闭红蜘蛛方法

热门文章

  1. 为什么网卡名称从eth0变成了enp*s*
  2. Flutter 生命周期
  3. 关于C++宏:AFX_EXT_CLASS
  4. 高级着色语言HLSL入门(7)
  5. python输出名片_Python的格式化输出--制作名片
  6. matlab中求方差的,matlab中求方差为什么除以n-1?
  7. Clion配置Ros环境
  8. 每天Leetcode 刷题 初级算法篇-颠倒二进制位
  9. 成都python数据分析师培训_python数据分析师
  10. Pandas——Series与DataFrame