集训-G. Swimming

G. Swimming

Problem Description

In the 2012 London Olympics, Sun Yang, the young Chinese swimmer, wins 2 golden medals and breaks the world record of men's 1500m freestyle. As a Chinese, we are proud of him, and as a ACMer, we can do some simple research on the results show system of the swimming.
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

The first line contain an integer T, which indicates the number of the test cases, Each test case consists of 9 lines. The first line is the Olympic Record and the World Record of the game(in the format of MM:SS.ss), and the followed by 8 lines, each line is the name of the swimmer and his/her result. The swimmers' names are all in uppercase letters and contain no space, and the result is in the format of MM:SS.ss. More details in the Sample Input. (Suppose that all the results are different)

Output

For each test case, the output contains 3 lines, the place of the fastest 3 swimmers or 'OR' or 'WR' and their names. There is a blank line between each case.

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

Fish
题意 给出8个人的成绩,找出前3名输出,且突出OR的排名时名次用OR代替,突出WR的排名时名次用WR代替

#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;
}

 链接:http://acm.hdu.edu.cn/diy/contest_showproblem.php?pid=1007&cid=16615&hide=0
 
posted @ 2012-08-12 16:40  jiai  Views(331)  Comments(0Edit  收藏  举报