题目大意:关于acm竞赛排名的题目,对于参赛者首先按做出的题目排名,然后是罚时,最后是编号。

  多关键字域排序问题。

  1. #include <cstdio>
  2. #include <cstring>
  3. #include <cctype>
  4. #include <iostream>
  5. #include <algorithm>
  6. using namespace std;
  7.  
  8. struct Cont
  9. {
  10. int id, num, t_penalty;
  11. int penalty[];
  12. bool solved[], join;
  13. bool operator < (const Cont & c) const
  14. {
  15. if (num != c.num) return num > c.num;
  16. if (t_penalty != c.t_penalty) return t_penalty < c.t_penalty;
  17. return id < c.id;
  18. }
  19. } cont[];
  20.  
  21. int main()
  22. {
  23. #ifdef LOCAL
  24. freopen("in", "r", stdin);
  25. #endif
  26. int T;
  27. scanf("%d", &T);
  28. getchar();
  29. char str[];
  30. gets(str);
  31. while (T--)
  32. {
  33. memset(cont, , sizeof(cont));
  34. for (int i = ; i <= ; i++)
  35. cont[i].id = i;
  36. while (gets(str) && str[])
  37. {
  38. int c, p, time;
  39. char ch;
  40. sscanf(str, "%d%d%d", &c, &p, &time);
  41. for (int i = strlen(str)-; i >= ; i++)
  42. if (isupper(str[i]))
  43. {
  44. ch = str[i];
  45. break;
  46. }
  47. cont[c].join = true;
  48. if (ch == 'C')
  49. {
  50. if (!cont[c].solved[p])
  51. {
  52. cont[c].num++;
  53. cont[c].penalty[p] += time;
  54. cont[c].solved[p] = true;
  55. }
  56. }
  57. else if (ch == 'I')
  58. {
  59. if (!cont[c].solved[p])
  60. cont[c].penalty[p] += ;
  61. }
  62. }
  63. for (int i = ; i <= ; i++)
  64. for (int j = ; j <= ; j++)
  65. if (cont[i].solved[j])
  66. cont[i].t_penalty += cont[i].penalty[j];
  67. sort(cont+, cont+);
  68. for (int i = ; i <= ; i++)
  69. if (cont[i].join)
  70. printf("%d %d %d\n", cont[i].id, cont[i].num, cont[i].t_penalty);
  71. if (T) printf("\n");
  72. }
  73. return ;
  74. }

  要注意的是,当一道题目正确提交后,以后对该题目的提交都对结果无影响。一直注意这点了,却忘了当一道题最终没有正确提交时,以前的错误提交是不计算罚时的,因为这个纠结了好长时间,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. 使用libvirt做适配的kvm虚拟机window server 2008 磁盘性能的提升

    实验室自己做了一个iaas的项目,当时是为了更方面的在kvm和xen下进行迁移,所以选择了libvirt作为适配层. 昨天简单的测试一了一下我们跟qingcloud的性能对比.我们的linux主机性能 ...

  2. Ubuntu root 密码设置及远程登录

    1. 修改 root 密码 sudo passwd root 2. 以其他账户登录,通过 sudo nano 修改 /etc/ssh/sshd_config : xxx@ubuntu14:~$ su ...

  3. 用TcpClient如何获取远程网页的内容

    用TcpClient如何获取远程网页的内容 private string GetHTMLTCP(string URL) { string strHTML = "";//用来保存获得 ...

  4. IIS判断W3WP进程对应哪个网站

    IIS 6 (Win2003 )中查看某个应用程序池对应那个 W3WP.exe 进程,可以使用如下命令,输出结果类似如下: C:\WINDOWS\system32>cscript iisapp. ...

  5. javascript之定义函数时 this 和prototype区别

    注:原文 http://www.2cto.com/kf/201406/307790.html 这里作为学习,写在这里 在面向对象的方式编写js脚本时,定义实例的方法主要有两种:this.XXX = f ...

  6. OGG 文档

    [OGG]OGG的下载和安装篇 http://www.cnblogs.com/lhrbest/p/4564013.html [OGG]OGG的单向DML复制配置(一) http://www.cnblo ...

  7. spring + hibernate 添加用户

    Employee.java: package com.lh.bean; public class Employee { private int id; private String name; pri ...

  8. DataSet和List<T> 泛型之间互相转换 (转载, 作者写的很好)

    /DataSet与泛型集合间的互相转换 //利用反射机制将DataTable的字段与自定义类型的公开属性互相赋值. //注意:从DataSet到IList<T>的转换,自定义类型的公开属性 ...

  9. Android开源项目收集

    软件名:gaeproxy软件作用:Android手机配置GoAgentFQ.项目地址:https://github.com/madeye/gaeproxy.git 软件名:ProxyDroid软件作用 ...

  10. (转)在Java中如何遍历Map对象

    在Java中如何遍历Map对象 How to Iterate Over a Map in Java 在java中遍历Map有不少的方法.我们看一下最常用的方法及其优缺点. 既然java中的所有map都 ...