题目大意:关于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. listview的简单封装

    package com.itheima.googleplay.ui.view; import android.content.Context; import android.graphics.Colo ...

  2. JavaBean--删除操作

    删除命令:removeAttribute(Javabean名称) 前面调用用pageContext,request,session,application, 如request.removeAttrib ...

  3. cisco 密码重置

    密码重置 分类: 转贴技术资料 2007-12-28 16:38 http://www.cisco.com/en/US/products/hw/routers/ps259/products_passw ...

  4. 转 shell脚本学习指南

    shell脚本学习指南 以下八点不敢说就能成为你shell脚本学习指南de全部,至少可以让你编写出可靠的shell脚本. 1. 指定bashshell 脚本的第一行,#!之后应该是什么?如果拿这个问题 ...

  5. Efim and Strange Grade

    Efim and Strange Grade time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. map map

    下面的无法运行. @Override protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Te ...

  7. Android--->activity高级运用,保存前一个界面为完成的数据savedInstanceState。

    main.xml布局代码分析 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xml ...

  8. Activity进程和线程之间的关系

    1,四大组件并不是程序(进程)的全部,只是他的零件. 2,应用程序启动后,将创建ActivityThread主线程. 3,同一包中的组件将运行在想通的进程空间里面. 4,不同包中的组件可以通过一定的方 ...

  9. python第三方扩展库及不同类型的测试需安装相对应的第三方库总结

    如何安装第三方库 1.通过python的第三方仓库pypi中查找想要的第三方库 pypi地址:https://pypi.python.org/pypi pip是一个安装和管理Python包的工具,通过 ...

  10. PAT (Advanced Level) 1012. The Best Rank (25)

    简单排序题. 注意:分数相同的人排名相同. #include<iostream> #include<cstring> #include<cmath> #includ ...