题目大意:关于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的更多相关文章

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

    http://www.cnblogs.com/sxiszero/p/3618737.html 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年 ...

  2. ACM训练计划step 1 [非原创]

    (Step1-500题)UVaOJ+算法竞赛入门经典+挑战编程+USACO 下面给出的题目共计560道,去掉重复的也有近500题,作为ACMer Training Step1,用1年到1年半年时间完成 ...

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

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

  4. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  5. 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 ...

  6. UVA 11865 Stream My Contest 组网 (朱刘算法,有向生成树,树形图)

    题意: 给n个点编号为0~n-1,0号点为根,给m条边(含自环,重边),每条边有个代价,也有带宽.给定c,问代价不超过c,树形图的最小带宽的最大值能达到多少? 思路: 点数才60,而带宽范围也不大,可 ...

  7. UVA 11865 Stream My Contest(最小树形图)

    题意:N台机器,M条有向边,总资金C,现要到搭建一个以0号机(服务器)为跟的网路,已知每条网线可以把数据从u传递到v,其带宽为d,花费为c,且d越大,传输速度越快,问能够搭建的传输速度最快的网络d值是 ...

  8. UVA 10600 ACM Contest and Blackout 次小生成树

    又是求次小生成树,就是求出最小生成树,然后枚举不在最小生成树上的每条边,求出包含着条边的最小生成树,然后取一个最小的 #include <iostream> #include <al ...

  9. 【UVA 10600】 ACM Contest and Blackout(最小生成树和次小生成树)

    [题意] n个点,m条边,求最小生成树的值和次小生成树的值. InputThe Input starts with the number of test cases, T (1 < T < ...

随机推荐

  1. sphinx分域搜索

    http://stackoverflow.com/questions/2526407/complex-query-with-sphinx 比如要实现和如下sql代码相同的功能: SELECT * FR ...

  2. php获取文件名

    php获取文件名$phpself =$_SERVER['PHP_SELF']; //获取当前文件名$str = end(explode("/",$phpself)); //去掉'/ ...

  3. mvc ChildActionOnly + ActionName的用法

    ChildActionOnly的目的主要就是让这个Action不通过直接在地址栏输入地址来访问,而是需要通过RenderAction来调用它. <a href="javascript: ...

  4. Struts2, jquery, select二级联动

    1. 下载jquery.js文件放在webroot下js文件夹里 2. 配置struts.xml: <package name="default" namespace=&qu ...

  5. 关于MySQL中时间格式和取零点的问题

    select * from order where create_time>'2016-05-21 00:00:00'; 不包含2016-05-21 00:00:00时的订单 select * ...

  6. jvm attach

    http://ayufox.iteye.com/blog/655761 管道通信

  7. Android----paint触摸轨迹监听

    paint触摸轨迹监听,主要是三种而已,ACTION_DOWN,ACTION_MOVE,ACTION_UP public boolean onTouchEvent(MotionEvent event) ...

  8. 在Gridview编辑时添加DropDownList控件并设置默认值

    页面代码: <asp:GridView ID="GridView1" runat="server"             AutoGenerateCol ...

  9. Allegro PCB -内层分割,比如电源层需要分割几种电源

    内层分割,比如电源层需要分割几种电源. (1).点击Display -> Assign Color 在Option中,先取一种颜色作为高亮显示的颜色. (2).在Find中,选Net,点击mor ...

  10. 打造最强Windows Server 2012 给你比Windows 8更好的体验

    每一代微软桌面操作系统推出的时候,都会同步推出相应核心的服务器操作系统,稳定性会更强哈 所以改造一下,让它保留兼容和专业的同时又有桌面操作系统的美观和便捷,多好 咳咳,让我们来看看怎么把Server ...