集训-G. Swimming
G. Swimming
Problem Description
When the swimmer touches the edge of the destination, the system will show the fastest 3 swimmers' names and their place. If the swimmer only breaks(strictly less than) the Olympic Record(OR), the numbers shows the place will replaced by the word 'OR'. If breaking the World Record(WR), the numbers shows the place will replaced by the word 'WR'.
Now your task is very simple. Given the swimmers' result, show the winners on the screen.
Input
Output
Sample Input
1 14:38.92 14:34.14 COCHRANE 14:40.34 SUN 14:31.02 MELLOULI 14:40.98 MIKE 15:00.83 BOELDS 15:01.02 SAUHWDNLWH 14:55.55 COBCASM 14:53.22 LISOFN 14:51.00
Sample Output
WR SUN 2 COCHRANE 3 MELLOULI
Author
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
struct Node
{
char t[100];
char s[100];
}node[100];
char n[100],m[100];
bool cmp( Node a,Node b)
{
return strcmp(a.t,b.t)<0;
}
int main( )
{
int test;
scanf("%d",&test);
for( int j=1;j<=test;j++)
{
scanf("%s%s",n,m);
for(int i=0;i<8;i++)
scanf("%s%s",node[i].s,node[i].t);
sort(node,node+8,cmp);
if(strcmp(n,m)>0)
{
for( int i=0;i<3;i++)
{
if(strcmp(node[i].t,m)<0)
printf("WR %s\n",node[i].s);
else if(strcmp(node[i].t,n)<0)
printf("OR %s\n",node[i].s);
else printf("%d %s\n",i+1,node[i].s);
}
}
else if(strcmp(n,m)<0)
{
for( int i=0;i<3;i++)
{
if(strcmp(node[i].t,n)<0)
printf("OR %s\n",node[i].s);
else if(strcmp(node[i].t,n)<0)
printf("WR %s\n",node[i].s);
else printf("%d %s\n",i+1,node[i].s);
}
}
puts("");
}
return 0;
}