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
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
Sample OutputA 180 2
B 250 10
C - -
D 299 10
E 295 7
题意:
找到一个题目AC最迟的一个队伍,一开始以为要排序,其实题目已经说了排序了。都是从小到大排序的。而且这题还有一个易错点就是如果重复提交AC那是算第一次还是最后一次,结果我用第一次的A了,而第二次就Wa了。还有要说的是一开始用sort();排序是不稳定的排序,所以wa了,所以排序都是会导致错误的。
AC代码:
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
#define T 1000100
typedef long long ll;
bool vis[50][500];
int val[500][2];
int main()
{
#ifdef zsc
freopen("input.txt","r",stdin);
#endif
int n,m,t,i,j,k;
while(~scanf("%d%d%d",&n,&t,&m))
{
memset(vis,false,sizeof(vis));
memset(val,-1,sizeof(val));
int time,team;
char s,str[5];
for(i=0;i<m;++i){
scanf(" %d %d %c %s",&time,&team,&s,&str);
if(strcmp(str,"Yes")!=0)continue;
int tmp = s-'A';
if(!vis[tmp][team]){
vis[tmp][team]=true;
val[tmp][0] = time;
val[tmp][1] = team;
}
}
for(i=0;i<n;++i){
printf("%c",i+'A');
if(val[i][0]==-1){
printf(" - -\n");
}
else {
printf(" %d %d\n",val[i][0],val[i][1]);
}
}
}
return 0;
}