#B3692. ICPC Roll Call Announcements

    ID: 11351 Type: Default 1000ms 256MiB

ICPC Roll Call Announcements

ICPC Roll Call Announcements

The contest lasts for 5 hours. In an ICPC contest, teams are ranked primarily by the number of problems solved and secondarily by the total penalty time. When two teams solve the same number of problems, the team with the smaller penalty time is ranked higher. In case both solved count and penalty time are identical, the team that appeared earlier in the submission records is considered to have a higher ranking.

The penalty time for a problem is computed as \(T + 20 \times R\), where \(T\) is the minute (\(\lfloor{\text{hour}*60+\text{minute}}\rfloor\)) at which the problem was solved (based on the submission time) and \(R\) is the number of rejected submissions before the submission that finally got accepted. Note that only the rejections for a problem which is eventually solved (either before or during the frozen period) are counted. Once a problem is solved, any further submission for that problem does not affect the team record.

During the contest, submissions in the first 4 hours (from 0:00:00 to 4:00:00) are judged immediately and appear on the scoreboard. In the last hour (from 4:00:01 to 5:00:00) the scoreboard is frozen – all submissions made in this period appear as pending on the scoreboard. After the contest ends, a roll call (or unfolding) phase takes place. The roll call host goes through the teams in the order they appeared on the frozen scoreboard, from the last rank to the first rank. For each team, the pending submissions are revealed in order of problem labels (from A onward). As soon as a revealed submission is judged Accepted and the team’s global ranking (re‐computed using all revealed results so far) improves compared to its ranking when its team name was last called, the host immediately announces that team’s name and then moves on to process the next team. (A team may have its name announced multiple times if its ranking continues to improve, until it reaches first place.)

Teams that have not made any submission will not appear on the scoreboard, and therefore, will not be announced.

inputFormat

The first line contains an integer n representing the number of submissions. Each of the following n lines contains a submission record in the following format:

HH:MM:SS TeamName ProblemID Verdict

where HH:MM:SS is the submission time (with 0 ≤ time ≤ 5:00:00), TeamName is a nonempty string without spaces, ProblemID is a single uppercase letter (e.g. A, B, …), and Verdict is one of: Accepted, Time Limit Exceeded, Memory Limit Exceeded, Presentation Error, Wrong Answer, or Runtime Error.

Submissions with time ≤ 04:00:00 are judged immediately, while those with time > 04:00:00 are frozen (i.e. pending) until the roll call phase. The time used for penalty is calculated by converting the HH:MM:SS to minutes using only the hour and minute components (i.e. ignoring seconds). For example, 01:28:35 is considered as 88 minutes.

outputFormat

Output the team names announced by the roll call host, one per line, in the order they are announced.

sample

3
00:30:00 TeamA A Accepted
04:15:00 TeamB A Accepted
00:50:00 TeamA B Wrong Answer