题目大意:关于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. Chapter 1 First Sight——12

    Breakfast with Charlie was a quiet event. 和查理斯吃早饭时一件安静的事情 He wished me good luck at school. I thanke ...

  2. 转:Eclipse Debug 界面应用详解——Eclipse Debug不为人知的秘密

    今天浏览csdn,发现一文详细的描述了Eclipse Debug中的各个知识点,非常详尽!特此记录. Eclipse Debug不为人知的秘密 http://blog.csdn.net/mgoann/ ...

  3. hdu_3549_Flow Problem(最大流)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=3549 题意:求1到n的最大流 题解:模版题,直接上Claris的ISAP,效率是一般dfs的十倍,OR ...

  4. 将json转化为model

    /// <summary> /// 获取Json的Model /// </summary> /// <typeparam name="T">&l ...

  5. Ubuntu将新增磁盘挂载到home下

    home磁盘空间不足,其他闲置硬盘是原来windows的,不能直接使用(磁盘格式及权限等原因),比如编译安卓源码等. 这样的话就需要将新的磁盘格式化成fat32后挂载到/home下的一个目录,这样就可 ...

  6. zf-关于收费统计没出来监利县的问题

    这个问题一看就知道跟存储过程有关,所以我直接去后台实现类找到了这个的存储过程 存储过程里第一句就是quhua_code  从 select 开始 就是查询出 4个地方的名字 然后在把这查询出的数据给@ ...

  7. 把MSSQL的表数据查询成 insert into格式的函数

    USE [db] GO /****** Object: StoredProcedure [dbo].[proc_insert] Script Date: 12/05/2012 17:18:31 *** ...

  8. FZU Problem 2150 Fire Game(bfs)

    这个题真要好好说一下了,比赛的时候怎么过都过不了,压点总是出错(vis应该初始化为inf,但是我初始化成了-1....),wa了n次,后来想到完全可以避免这个问题,只要入队列的时候判断一下就行了. 由 ...

  9. @Resource @Autowired 区别

    spring2.5提供了基于注解(Annotation-based)的配置,我们可以通过注解的方式来完成注入依赖.在Java代码中可以使用 @Resource或者@Autowired注解方式来经行注入 ...

  10. CentOS 7 x64 docker 使用点滴

    CentOS 7 安装 docker yum search docker  查看是否 有docker包 yum info docker  版本为1.3.2 yum -y install docker ...