Background
We knew something would be missing. We have just noticed that we do not have a tool helping us with the ranking list for this programming contest, and if we tried to create it by hand, you would probably end up waiting for the results until Sunday. So please help us out here, will you?
Problem
Your task is to write a program that determines the ranking list for a programming contest. You are given a list of the participating teams and a log file describing all the solutions submitted by the teams.
The scoring of this programming contest is based on the following set of rules:
The first line contains the number of scenarios.
For each scenario, you find the number n, 1 <= n <= 20, of teams in the first line and the (unique) names of the teams in the n following lines. A team name is a single word of length at most 8 containing letters and digits only, and for your convenience the teams are listed in alphabetical order. The next line contains the number k of problems and the number m of solutions that were submitted (1 <= k < 10, 0 <= m <= 2000). Each of the following m lines describes one such solution, in the format "problem time correctness team", where 1 <= problem <= k is the number of the problem,0 <= time < 300 is the number of minutes elapsed since the contest was started, correctness is either "Yes" or "No" and team is the name of the team that submitted the solution. You can assume that the lines in the log file are sorted by time.
For each scenario print a ranking list containing every team that participated in the contest. The format is "rank. team solved time", where rank is the rank, team the name of the team, solved the number of correct solutions, and time the total time. In addition to the single blanks separating these four fields, make the table look nice by using a field width of 2 for the rank, 8 for the team's name, 1 for the number of problems solved and 4 for the total time (name left-adjusted, numbers right-adjusted, see sample output). Each scenario ends with a blank line.
2 10 Team1 Team2 Team3 Team4 Team5 Team6 Team7 Team8 Team9 slowTeam 8 14 1 18 Yes Team4 1 57 Yes Team2 1 87 Yes Team3 1 101 Yes Team1 2 103 Yes Team5 2 120 Yes Team6 6 141 Yes Team7 1 147 No Team1 7 156 Yes Team2 5 167 Yes Team8 2 167 Yes Team9 5 170 No Team4 5 175 Yes Team4 1 234 No slowTeam 1 Team1 8 0
1. Team2 2 213 1. Team4 2 213 3. Team3 1 87 4. Team1 1 101 5. Team5 1 103 6. Team6 1 120 7. Team7 1 141 8. Team8 1 167 8. Team9 1 167 10. slowTeam 0 0 1. Team1 0 0