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. Lazarus -Pascal常量

    2.常量 2.1.普通常量 仅仅下面类型可以被定义为常量Ordinal类型Set类型指针类型 (but the only allowed value is Nil). real类型 Char, Str ...

  2. 【转】Java 5种字符串拼接方式性能比较。

    最近写一个东东,可能会考虑到字符串拼接,想了几种方法,但对性能未知,于是用Junit写了个单元测试. 代码如下: import java.util.ArrayList; import java.uti ...

  3. hibernate多SessionFactory配置

    <bean id="aDataSource" class="org.apache.commons.dbcp.BasicDataSource" destro ...

  4. json格式的转换为json字符串函数

    function toJSON(object){ var type = typeof object; if ('object' == type) { if (Array == object.const ...

  5. 面向对象之abstract

    1.abstract class,抽象类不能被实例化,只能被继承:抽象类中可以包含非抽象方法 2.abstract method();抽象方法只能在抽象类中进行声明,并且没有方法体,非抽象继承子类中必 ...

  6. Macro and SQL

    If you’ve developed anything in the supply chain area, you’ve most probably come across InventDimJoi ...

  7. Introduction to Project Management(II)

    Introduction The purpose of this paper is to gain an understanding of project management and to give ...

  8. Swift-11-协议(Protocols)

    协议定义了一个蓝图,规定了用来实现某一特定工作或者功能所必须的方法和属性.类.结构体或者枚举类型都可以遵循协议,并提供具体实现来完成协议定义的方法和功能.任意能满足协议要求的类型被称为遵循confor ...

  9. debian linux下配置lnmp环境

    用到哪些就安装哪些 安装配置时遇到: deb cdrom:[Debian GNU/Linux 7.1.0 _Wheezy_ - Official amd64 CD Binary-1 20130615- ...

  10. Nginx反向代理的模拟

    CentOS起两台tomcat,端口分别是8080和8081! 1. nginx配置文件:nginx.conf upstream tomcats{ server 192.168.198.128:808 ...