http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1339

1339: 最后一滴血

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 319  Solved: 142
[Submit][Status][Web Board]

Description

在ACM/ICPC这样的程序设计竞赛中,最早解出一道题称为抢到FB(First Blood,第一滴血)。现在ACM/ICPC世界总决赛甚至为每道题的FB设立了特别奖。

也许我们还可以设一个LB(Last Blood,最后一滴血)奖,奖给最后一个解出某题的队伍。注意:你不能先提交程序,得到Yes之后等比赛快结束时把它再交一遍,因为一旦一只队伍解出了某题,它对该题的所有后续提交都会被忽略。所有有本事的话,应该是写完程序以后先不交,等到比赛快结束时才交。当然,这样做浪费了很多罚时并且还有WA的风险,所以LB奖才显得有趣。

输入一场比赛中所有提交和对应的结果,输出每道题的LB奖得主。

Input

输入仅包含一组数据。第一行为题数n、队伍数t和提交数m(5<=n<=12, 10<=t<=100, 1<=m<=1000)。以下m行每行包含time(0~300之间的整数,单位:分钟), teamID(1~t), problem(A~L)和结果(Yes或者No)。提交按照时间从小到大排序,所以即使两个提交的time相同,也有先后顺序(可能只差几秒钟)。任意两个提交的时间都不会完全相同,因此LB奖要么空缺,要么有惟一的得主。

Output

对于每组数据,输出每道题目的LB奖得主的提交时间和teamID,格式见样例。

Sample Input

5 10 18
0 2 B No
11 2 B Yes
20 3 A Yes
35 8 E No
40 8 E No
45 7 E No
50 10 A Yes
100 4 A No
120 6 B Yes
160 2 E Yes
180 2 A Yes
210 3 B Yes
240 10 B No
250 10 B Yes
270 2 B Yes
295 8 E Yes
295 7 E Yes
299 10 D Yes

Sample Output

A 180 2
B 250 10
C - -
D 299 10
E 295 7

HINT

分析:

用一个数组结构体存储做对该题目的队伍的ID和时间,然后比较找出最后一个提交的队伍和时间。

AC代码:

 #include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <iomanip>
#include <vector>
#pragma comment(linker, "/STACK:1024000000,1024000000")
#pragma warning(disable:4786) using namespace std; const int INF = 0x3f3f3f3f;
const int MAX = + ;
const double eps = 1e-;
const double PI = acos(-1.0); struct T
{
int time , id;
char a , s[];
}p[]; struct T1
{
int time , id;
}f[]; int main()
{
int n , t , m , i , l , ll , maxn = , ff[][];
scanf("%d %d %d",&n , &t , &m);
memset(ff , , sizeof(ff));
for(i = ;i <= n;i ++)
f[i].time = -;
for(i = ;i < m;i ++)
{
scanf("%d %d %c %s",&p[i].time , &p[i].id , &p[i].a , p[i].s);
l = p[i].a - 'A' + ;
ll = p[i].id;
if(l > maxn)
maxn = l;
if(strcmp(p[i].s , "Yes") == )
{
ff[ll][l] ++;
if(ff[ll][l] == && p[i].time >= f[l].time)
{
f[l].time = p[i].time;
f[l].id = p[i].id;
}
ff[ll][l] ++;
}
}
for(i = ;i <= maxn;i ++)
{
if(f[i].time == -)
printf("%c - -\n",i - + 'A');
else
printf("%c %d %d\n", i - + 'A' , f[i].time , f[i].id);
}
return ;
}

csu oj 1339: 最后一滴血的更多相关文章

  1. csu oj 1330 字符识别?

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1330 1330: 字符识别? Time Limit: 1 Sec  Memory Limit: 1 ...

  2. csu oj 1811: Tree Intersection (启发式合并)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1811 给你一棵树,每个节点有一个颜色.问删除一条边形成两棵子树,两棵子树有多少种颜色是有 ...

  3. csu oj 1804: 有向无环图 (dfs回溯)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 中文题意就不说了. dfs从底到根回溯即可,看代码应该能清楚. //#pragma ...

  4. csu oj 1344: Special Judge

    Description Given a positive integer n, find two non-negative integers a, b such that a2 + b2 = n. I ...

  5. csu oj 1343 Long Long

    Description 现在有两个单调递增序列,第一个序列有N个整数,第二个序列有M个整数,现在你可以从第一个序列中选一个数x,然后从第二个序列中选一个数y,那么有多少种情况满足x+y<=K呢? ...

  6. csu oj 1341 string and arrays

    Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...

  7. CSU OJ 1340 A Sample Problem

    Description My girlfriend loves 7 very much, she thinks it is lucky! If an integer contains one or m ...

  8. 九度OJ 1339:ACM (排序)

    时间限制:1 秒 内存限制:32 兆 特殊判题:否 提交:712 解决:379 题目描述: 今年的ACM世界总决赛快要开始了,需要有一个排名算法来对每支队伍进行现场排名.ACM组委会把这个任务交给了你 ...

  9. CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。

    1514: Packs Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 61  Solved: 4[Submit][Status][Web Board] ...

随机推荐

  1. DefaultHttpClient使用

    转自:http://username2.iteye.com/blog/1664995 博客分类:  java 工具类 javaio  ]; } json = JSONObject.fromObject ...

  2. java Channel

    Channel Channel与流 基本上,所有的 IO 在NIO 中都从一个Channel 开始.Channel 有点象流.数据可以从Channel读到Buffer中,也可以从Buffer 写到Ch ...

  3. 蓝牙的L2CAP协议

    1.概述     L2CAP能向上层提供面向连接的或者无连接的数据服务,拥有multiplexing capability and segmentation and reassembly operat ...

  4. scala 学习笔记

    1.简洁 1.1.java的写法 class MyClass { private int index; private String name; public MyClass(int index, S ...

  5. Tinyxml的简单应用

    参考文章: 1-> http://www.cnblogs.com/phinecos/archive/2008/03/11/1100912.html 2-> http://blog.csdn ...

  6. MVC分页控件之二,为IQueryable定义一个扩展方法,直接反回PagedList<T>结果集(转)

    namespace Entity { public interface IPagedList { /// <summary> /// 记录数 /// </summary> in ...

  7. Magento 安装时文件权限 设置

    http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/magento_filesystem_permission ...

  8. diff命令和patch命令

    diff命令和patch命令 Linux就这个范儿 2.9.5 文件对比命令——diff diff命令搭建网站离不开数据库,在Linux系统上我们使用源码安装了MySQL服务器.不久我们发现 Goog ...

  9. Linux下设置网卡静态ip

    Linux下设置网卡静态ip 如果是服务器版,没有图形界面只用用命令行修改配置文件 如果是客户端版本,可以用图形界面 配置的前提是要在root用户下才能重启网卡服务 图形界面: system-conf ...

  10. python模块(sys)

    SYS模块 sys.argv # 命令行参数List,第一个元素是程序本身路径 sys.exit(n) # 退出程序,正常退出时exit(0) sys.version # 获取Python解释程序的版 ...