Problem C
Race Day

You are responsible for keeping track of and reporting the results for the runners in a race. You want to develop a software package to make this easier for you. Your program should present the results for all runners in one table, ranking each runner based on their overall time and split times. Split times are measured from the beginning of the race to the split point (e.g. in a $5$ km race there may be split points at $2$ km and $4$ km). You may assume there are always $2$ splits per race, plus the finish time. The whole table should be ordered by the runner’s last name, then first name. All runner’s names are unique.

One of the issues your program must deal with is collecting the data from disparate sources. Since you have multiple people recording times of runners at each timing location, the information may come to you in any order, and is not grouped by runner. Each timing result is identified by the runner’s bib number as well as which location it came from. You should collect all the information by runner, and organize it as above.


Input consists of data from up to $10$ races. Process each race separately. Each race’s input begins with a positive integer $1 \le n \le 500$, followed by a list of $n$ runner descriptions. Each runner description has a runners name (first name followed by last name) and bib number. A bib number is a $5$-digit number (possibly including leading zeros), unique to that runner for that race. Following the runner descritipions are $3n$ timing records. Each record has three parts: the bib number, followed by the location (S1 for split 1, S2 for split 2, or F for finish), followed by the time (using the format MM:SS). Each name is made of only alphabet characters (a–z).

The last test case is followed by a line containing only the number 0.


For each race, print a formatted table giving last name, comma, first name, bib number, then the time and rank for the two splits and the finish. The name column should be $20$ characters wide, left-justified. All remaining columns should be $10$ characters wide, right-justified. Each table should have a header formatted as shown in the sample output.

If two or more runners have the same time, they should be ranked equally as the highest possible rank, but the ranking for slower runners should remain the same. For example, if two runners tie for first place, they are each given rank $1$, but the next runner should be given rank $3$.

Follow the format of the sample output.

Sample Input 1 Sample Output 1
Bert Trista 00227
Joanne Valeria 00248
Elaina Eduardo 00615
Iona Scott 00234
Jon Idella 00014
00234 S2 31:05
00234 F 55:25
00248 S2 37:24
00615 S1 17:54
00227 F 52:41
00615 S2 32:22
00234 S1 16:58
00248 F 53:18
00014 F 56:26
00014 S1 17:57
00227 S1 20:40
00248 S1 21:13
00014 S2 32:22
00227 S2 34:55
00615 F 51:22
Bernardo Lesa 31183
Thad Kellie 28712
Claudia Brigette 38522
38522 S1 25:21
38522 S2 30:36
31183 S1 23:15
31183 S2 29:28
28712 F 53:21
28712 S2 33:31
31183 F 41:17
28712 S1 23:50
38522 F 45:09
NAME                       BIB    SPLIT1      RANK    SPLIT2      RANK    FINISH      RANK
Eduardo, Elaina          00615     17:54         2     32:22         2     51:22         1
Idella, Jon              00014     17:57         3     32:22         2     56:26         5
Scott, Iona              00234     16:58         1     31:05         1     55:25         4
Trista, Bert             00227     20:40         4     34:55         4     52:41         2
Valeria, Joanne          00248     21:13         5     37:24         5     53:18         3

NAME                       BIB    SPLIT1      RANK    SPLIT2      RANK    FINISH      RANK
Brigette, Claudia        38522     25:21         3     30:36         2     45:09         2
Kellie, Thad             28712     23:50         2     33:31         3     53:21         3
Lesa, Bernardo           31183     23:15         1     29:28         1     41:17         1

CPU Time limit 1 second
Memory limit 1024 MB
Statistics Show
Greg Hamerly
Source Baylor Competitive Learning course
License Creative Commons License (cc by-sa)

Please log in to submit a solution to this problem

Log in