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. wsdl 结构

    WSDL文档可以分为两部分.分别是抽象部分和具体描述 部分. 抽象部分 抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随 机器或语言而变的元素.<types>.< ...

  2. WGZX:javaScript 学习心得--1

    标签: javascriptiframedreamweaver浏览器htmltable 2008-09-11 10:50 1071人阅读 评论(0) 收藏 举报  分类: UI(21)  1,docu ...

  3. Best practice: escape, or encodeURI / encodeURIComponent

    escape() Don't use it, as it has been deprecated since ECMAScript v3. encodeURI() Use encodeURI when ...

  4. FastMM、FastCode、FastMove的使用(图文并茂)

    FastMM是一个替换Embarcadero Delphi Win32应用程序的快速内存管理器,以及可以在多线程下使用,不容易产生内存碎片,并且无需使用外部DLL文件就可以支持共享内存. 使用方法:1 ...

  5. 【VC6】【集成工具】将输入信息集成到VC工具中

    1.首先写一个工具,可以接受外部参数, 并且输入格式必须是固定的“"%s(%d):\n", __FILE__, __LINE__”形式. 2.编译生成EXE准备进行使用: 3.在V ...

  6. style="display"之后不能获取offsetHeight或clientWidth这类测量的值

    如果在html元素中设置了style="display:none;height:90px;"的属性后,是无法获得offsetLeft ,offsetWidth,offsetTop, ...

  7. css背景图片定位练习(一)

    首先准备一张雪碧图,Like this 背景图片的定位方法有3种,比较常用的两种为 关键字:background-position: top left; (top/bottom/cennter/lef ...

  8. java的Random

    首先,Point类 public class Point { int x, y; public Point(int x, int y) { this.x = x; this.y = y; } bool ...

  9. ubuntu12.04 登录黑屏

    新安装的ubuntu12.04LTS,登录之后黑屏,切换到ubuntu2D能够进入UI.解决方法记录于此. 转载: http://blog.csdn.net/albertsh/article/deta ...

  10. spring mvc 静态资源 404问题

    spring mvc 静态资源 404问题 在web.xml配置servlet-mapping的时候,如果url-pattern设置为"/" (如下),很多人都会遇到导入js,cs ...