UVa 10258 - Contest Scoreboard
题目大意:关于acm竞赛排名的题目,对于参赛者首先按做出的题目排名,然后是罚时,最后是编号。
多关键字域排序问题。
#include <cstdio>
#include <cstring>
#include <cctype>
#include <iostream>
#include <algorithm>
using namespace std; struct Cont
{
int id, num, t_penalty;
int penalty[];
bool solved[], join;
bool operator < (const Cont & c) const
{
if (num != c.num) return num > c.num;
if (t_penalty != c.t_penalty) return t_penalty < c.t_penalty;
return id < c.id;
}
} cont[]; int main()
{
#ifdef LOCAL
freopen("in", "r", stdin);
#endif
int T;
scanf("%d", &T);
getchar();
char str[];
gets(str);
while (T--)
{
memset(cont, , sizeof(cont));
for (int i = ; i <= ; i++)
cont[i].id = i;
while (gets(str) && str[])
{
int c, p, time;
char ch;
sscanf(str, "%d%d%d", &c, &p, &time);
for (int i = strlen(str)-; i >= ; i++)
if (isupper(str[i]))
{
ch = str[i];
break;
}
cont[c].join = true;
if (ch == 'C')
{
if (!cont[c].solved[p])
{
cont[c].num++;
cont[c].penalty[p] += time;
cont[c].solved[p] = true;
}
}
else if (ch == 'I')
{
if (!cont[c].solved[p])
cont[c].penalty[p] += ;
}
}
for (int i = ; i <= ; i++)
for (int j = ; j <= ; j++)
if (cont[i].solved[j])
cont[i].t_penalty += cont[i].penalty[j];
sort(cont+, cont+);
for (int i = ; i <= ; i++)
if (cont[i].join)
printf("%d %d %d\n", cont[i].id, cont[i].num, cont[i].t_penalty);
if (T) printf("\n");
}
return ;
}
要注意的是,当一道题目正确提交后,以后对该题目的提交都对结果无影响。一直注意这点了,却忘了当一道题最终没有正确提交时,以前的错误提交是不计算罚时的,因为这个纠结了好长时间,WA的好惨...看别人代码时心里还在想“干嘛多次一举保存每个题的罚时?”,忽然就明白了,是我错了...
UVa 10258 - Contest Scoreboard的更多相关文章
- (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO
http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...
- ACM训练计划step 1 [非原创]
(Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...
- 算法竞赛入门经典+挑战编程+USACO
下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成.打牢基础,厚积薄发. 一.UVaOJ http://uva.onlinej ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
- Root :: AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 5. Dynamic Programming
10192 最长公共子序列 http://uva.onlinejudge.org/index.php?option=com_onlinejudge& Itemid=8&page=sho ...
- UVA 11865 Stream My Contest 组网 (朱刘算法,有向生成树,树形图)
题意: 给n个点编号为0~n-1,0号点为根,给m条边(含自环,重边),每条边有个代价,也有带宽.给定c,问代价不超过c,树形图的最小带宽的最大值能达到多少? 思路: 点数才60,而带宽范围也不大,可 ...
- UVA 11865 Stream My Contest(最小树形图)
题意:N台机器,M条有向边,总资金C,现要到搭建一个以0号机(服务器)为跟的网路,已知每条网线可以把数据从u传递到v,其带宽为d,花费为c,且d越大,传输速度越快,问能够搭建的传输速度最快的网络d值是 ...
- UVA 10600 ACM Contest and Blackout 次小生成树
又是求次小生成树,就是求出最小生成树,然后枚举不在最小生成树上的每条边,求出包含着条边的最小生成树,然后取一个最小的 #include <iostream> #include <al ...
- 【UVA 10600】 ACM Contest and Blackout(最小生成树和次小生成树)
[题意] n个点,m条边,求最小生成树的值和次小生成树的值. InputThe Input starts with the number of test cases, T (1 < T < ...
随机推荐
- JSP文件上传--FileUpload组件
如果使用上传操作,并且没有使用框架之类,最好使用Smartupload,因为FileUpdate太难使用. 下载组件: fileupload包:http://commons.apache.org/pr ...
- C# 经典入门12章-使用泛型类型-2
- zf-关于荆州首页鼠标移动到导航栏上去触发的js 显示 问题解决办法
是我copy代码的 时候 这个触发的属性没有修改,导致出现BUG,改成mopen('m2') 就好了
- Android平台中实现对XML的三种解析方式
本文介绍在Android平台中实现对XML的三种解析方式. XML在各种开发中都广泛应用,Android也不例外.作为承载数据的一个重要角色,如何读写XML成为Android开发中一项重要的技能. 在 ...
- SDAU课程练习--problemA(1000)
题目描述 The famous ACM (Advanced Computer Maker) Company has rented a floor of a building whose shape i ...
- 原生 JS Ajax,GET和POST 请求实例代码
javascript/js的ajax的GET请求代码如下所示: <script type="text/javascript"> /* 创建 XMLHttpRequest ...
- input file图片上传预览
两种方法,方法一: js代码: //头像上传预览 $("#up").change(function() { var $file = $(this); var fileObj = $ ...
- 执行 apt-get -f install 提示错误
执行 apt-get -f install 提示错误 分类: Linux 2015-01-24 21:26 554人阅读 评论(0) 收藏 举报 1. 问题: usloft1359:~# rvm in ...
- CentOS新增开机启动项
编辑rc.local文件 vi /etc/rc.d/rc.local 例如 #!/bin/sh # # This script will be executed *after* all the oth ...
- 考分鄙视(exam)
考分鄙视(exam) 题目描述 Whence这个学期考了n次试,每一次都有一个0-20000之间的整数分数.Whence本来的状态应该是每一次考试都比前一次多一分(除第一次),但由于他很不稳定,偏差可 ...