The Ninth Hunan Collegiate Programming Contest (2013) Problem L

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[18] ;
set<Node>problem[18] ;

int  N , M , T ;
int main(){
   cin>>N>>M>>T ;
   for(int i=0;i<N;i++){
       problem[i].clear() ;
       problem_man[i].clear() ;
   }
   int time ,team;
   string problem_id ,answer ;
   for(int t=1;t<=T;t++){
       cin>>time>>team>>problem_id>>answer ;
       int id=problem_id[0]-'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=0;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 0 ;
}

 

转载于:https://www.cnblogs.com/liyangtianmen/p/3367241.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值