Problem L

Last Blood

In many programming contests, special prizes are given to teams who solved a particular problem first. We call the first accepted solution "First Blood".

It's an interesting idea to set prizes for "Last Blood". Then people won't submit their solutions until the last minute. But this is dangerous: if the solution got "Wrong Answer" or even "Time limit exceeded", it may be too late to correct the solution.

You may argue that once a submission got "Accepted", the team can send it again, but in this problem, we only consider the earliest accepted solution of a team for each problem, so re-sending an accepted solution does NOT help!

Given all the submissions in a contest, your task is to find out the "Last Blood" prizes for each problem.

Input

There is only one test case. The first line contains three integer n, t, m (5<=n<=12, 10<=t<=100, 1<=m<=1000), the number of problems, teams and submissions. Each of the following m lines describes one submission: time (0<=time<=300), teamID(1~t), problem (A~L) and verdict("Yes" or "No"). Submissions are sorted in time order. That means for two submissions of the same "time" field, the submission that comes later in the input is received later in the contest (maybe only a few seconds later). No two submissions are received in exactly the same time.

Output

For each problem, print the last blood's time and 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

Output for the Sample Input

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

The Ninth Hunan Collegiate Programming Contest (2013) Problemsetter: Rujia Liu Special Thanks: Md. Mahbubul Hasan

   记在这个地方主要是怕以后忘记接口,也方便大家交流,可能方法很傻吧。

#include <iostream>
#include <stdio.h>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <stack>
#include <math.h>
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std ;
typedef long long LL ; struct Node{
int team ;
int time ;
int id ;
Node(){} ;
Node(int i ,int te,int ti):id(i),team(te),time(ti){} ;
friend bool operator <(const Node A ,const Node B){
if(A.time==B.time)
return A.id>B.team ;
else
return A.time>B.time ;
}
};
set<int>problem_man[] ;
set<Node>problem[] ; int N , M , T ;
int main(){
cin>>N>>M>>T ;
for(int i=;i<N;i++){
problem[i].clear() ;
problem_man[i].clear() ;
}
int time ,team;
string problem_id ,answer ;
for(int t=;t<=T;t++){
cin>>time>>team>>problem_id>>answer ;
int id=problem_id[]-'A' ;
if(answer=="Yes"){
if(problem_man[id].find(team)==problem_man[id].end()){
problem_man[id].insert(team) ;
problem[id].insert(Node(t,team,time)) ;
}
}
}
set<Node>::iterator p ;
for(int i=;i<N;i++){
if(problem[i].size()){
p=problem[i].begin() ;
printf("%c %d %d\n",'A'+i,p->time ,p->team) ;
}
else
printf("%c - -\n",'A'+i ) ;
}
return ;
}

The Ninth Hunan Collegiate Programming Contest (2013) Problem L的更多相关文章

  1. The Ninth Hunan Collegiate Programming Contest (2013) Problem A

    Problem A Almost Palindrome Given a line of text, find the longest almost-palindrome substring. A st ...

  2. The Ninth Hunan Collegiate Programming Contest (2013) Problem F

    Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roa ...

  3. The Ninth Hunan Collegiate Programming Contest (2013) Problem H

    Problem H High bridge, low bridge Q: There are one high bridge and one low bridge across the river. ...

  4. The Ninth Hunan Collegiate Programming Contest (2013) Problem I

    Problem I Interesting Calculator There is an interesting calculator. It has 3 rows of button. Row 1: ...

  5. The Ninth Hunan Collegiate Programming Contest (2013) Problem J

    Problem J Joking with Fermat's Last Theorem Fermat's Last Theorem: no three positive integers a, b, ...

  6. The Ninth Hunan Collegiate Programming Contest (2013) Problem G

    Problem G Good Teacher I want to be a good teacher, so at least I need to remember all the student n ...

  7. The Ninth Hunan Collegiate Programming Contest (2013) Problem C

    Problem C Character Recognition? Write a program that recognizes characters. Don't worry, because yo ...

  8. German Collegiate Programming Contest 2013:E

    数值计算: 这种积分的计算方法很好,学习一下! 代码: #include <iostream> #include <cmath> using namespace std; ; ...

  9. German Collegiate Programming Contest 2013:B

    一个离散化的简单题: 我用的是STL来做的离散化: 好久没写离散化了,纪念一下! 代码: #include<cstdio> #include<cstring> #include ...

随机推荐

  1. hadoop(二):hdfs HA原理及安装

    早期的hadoop版本,NN是HDFS集群的单点故障点,每一个集群只有一个NN,如果这个机器或进程不可用,整个集群就无法使用.为了解决这个问题,出现了一堆针对HDFS HA的解决方案(如:Linux ...

  2. [Hibernate] - Study 1

    1)解压Hibernate,在eclipse中导入jar包,其中lib\required里的jar包是必需包括在里头的.这里用的是sql server,所以要导入sqljdbc4.jar 2)在src ...

  3. 01TCP/IP基础

    ISO/OSI参考模型: OSI(open system interconnection)开放系统互联模型是由ISO(International Organization for Standardiz ...

  4. vs2010 release 模式加了断点,跑代码无法跟踪,解决方法

    纯跑代码,不是附加进程调试. 打开不能调试的类库项目属性页面→切换到生成选项卡→点击高级按钮→将调试信息一项设置 将“调试信息”设置为“pdb-only”.  我是按图上的设置就正常了. -- 201 ...

  5. 剑指offer系列51---扑克牌顺子

    [题目]抽五张扑克牌,判断五张扑克牌是不是顺子,大小王可看做任何数,0代替. package com.exe10.offer; import java.util.Arrays; /** * [题目]抽 ...

  6. String、StringBuffer、StringBuilder之间的区别

    String                      字符串常量 StringBuffer         字符串变量(线程安全) StringBuilder       字符串变量(非线程安全) ...

  7. ORA-04031案例一则

    ORA-04031这个错误,几乎每一个专业的DBA都遇到过.这是一个相当严重的错误,Oracle进程在向SGA申请内存时,如果申请失败,则会报这个错误.大部分情况下是在向SGA中的shared poo ...

  8. 【转】c# winform DataGridView导出数据到Excel中,可以导出当前页和全部数据

    准备工作就是可以分页的DataGridView,和两个按钮,一个用来导出当前页数据到Excel,一个用来导出全部数据到Excel 没有使用SaveFileDialog,但却可以弹出保存对话框来 先做导 ...

  9. JavaScript中Call()以及Apply()的应用

    apply()和call()的真正用武之地是能够扩充函数赖以运行的作用域 三点说明: 1.每个函数都包含两个非继承而来的方法:apply()和call(). 2.他们的用途相同,都是在特定的作用域中调 ...

  10. sessionStorage、localStorage简介

    简介 技术一般水平有限,有什么错的地方,望大家指正. sessionStorage.localStorage.cookie这三个是我们在浏览器端用来存储数据的,cookie使用起来较为繁琐以后进行总结 ...