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 < ...
随机推荐
- 使用libvirt做适配的kvm虚拟机window server 2008 磁盘性能的提升
实验室自己做了一个iaas的项目,当时是为了更方面的在kvm和xen下进行迁移,所以选择了libvirt作为适配层. 昨天简单的测试一了一下我们跟qingcloud的性能对比.我们的linux主机性能 ...
- Ubuntu root 密码设置及远程登录
1. 修改 root 密码 sudo passwd root 2. 以其他账户登录,通过 sudo nano 修改 /etc/ssh/sshd_config : xxx@ubuntu14:~$ su ...
- 用TcpClient如何获取远程网页的内容
用TcpClient如何获取远程网页的内容 private string GetHTMLTCP(string URL) { string strHTML = "";//用来保存获得 ...
- IIS判断W3WP进程对应哪个网站
IIS 6 (Win2003 )中查看某个应用程序池对应那个 W3WP.exe 进程,可以使用如下命令,输出结果类似如下: C:\WINDOWS\system32>cscript iisapp. ...
- javascript之定义函数时 this 和prototype区别
注:原文 http://www.2cto.com/kf/201406/307790.html 这里作为学习,写在这里 在面向对象的方式编写js脚本时,定义实例的方法主要有两种:this.XXX = f ...
- OGG 文档
[OGG]OGG的下载和安装篇 http://www.cnblogs.com/lhrbest/p/4564013.html [OGG]OGG的单向DML复制配置(一) http://www.cnblo ...
- spring + hibernate 添加用户
Employee.java: package com.lh.bean; public class Employee { private int id; private String name; pri ...
- DataSet和List<T> 泛型之间互相转换 (转载, 作者写的很好)
/DataSet与泛型集合间的互相转换 //利用反射机制将DataTable的字段与自定义类型的公开属性互相赋值. //注意:从DataSet到IList<T>的转换,自定义类型的公开属性 ...
- Android开源项目收集
软件名:gaeproxy软件作用:Android手机配置GoAgentFQ.项目地址:https://github.com/madeye/gaeproxy.git 软件名:ProxyDroid软件作用 ...
- (转)在Java中如何遍历Map对象
在Java中如何遍历Map对象 How to Iterate Over a Map in Java 在java中遍历Map有不少的方法.我们看一下最常用的方法及其优缺点. 既然java中的所有map都 ...