#P8890. ICPC Rolling Announcement
ICPC Rolling Announcement
ICPC Rolling Announcement
A 5-hour ICPC contest is held. The ranking is determined by the number of solved problems and the total penalty time. In particular, for each solved problem, the penalty is calculated as the number of minutes from the start of the contest when the problem was solved, plus $20$ minutes for each previous unsuccessful submission. Note that only submissions on a problem after it has been solved (in either phase) are ignored. If two teams have the same number of solved problems and the same penalty, then the team that appears earlier in the submission record (i.e. with a smaller first appearance index) is ranked higher.
The contest is divided into two phases. In the first 4 hours (from 00:00:00
to 04:00:00
), every submission is judged immediately and the results are reflected on the scoreboard. In the last hour (from 04:00:01
to 05:00:00
), the scoreboard is frozen; submissions are accepted by the judging system but are shown as pending on the scoreboard.
After the contest, a dramatic rolling score process occurs. The roll-call announcer goes through the teams according to the freeze ranking (i.e. based solely on submissions before 4 hours) in order from the last place to the first place. For each team, the announcer first reads the team name, and then, in alphabetical order from problem A to the last problem, the final status of each "pending" problem is revealed. If the final verdict for a pending problem is Accepted
, the team’s score is updated accordingly (i.e. increasing the solved count and adding the corresponding penalty, where the penalty accrues from both the freeze phase wrong submissions and the pending submissions before the accepted one). Note that if a team never solved a problem in the freeze, even if it made many pending submissions, only if a pending submission is eventually revealed as accepted will its penalty be counted.
After each pending revelation for a team, the overall standings (ranking all teams by solved problems descending, penalty ascending, and tie‐broken by the order of first appearance in the submission record) are recalculated. If the team’s ranking improves (that is, its rank number decreases) compared to its ranking immediately before revealing that pending problem, then the announcer immediately stops revealing further pending submissions for that team and reads the team name again. (Once a team reaches first place, further accepted revelations cannot improve its ranking, so that team will not be reannounced.)
Given the complete submission record of a contest, output, in order, all team names as announced by the roll-call announcer. A team that does not have any submission will not appear anywhere.
The time in any submission is given in HH:MM:SS format. For penalty calculations, use only the hour and minute (i.e. for a submission time HH:MM:SS, the minute count is 60×HH+MM
; seconds are ignored). For example, if a team solved a problem at 01:28:35
and had 3 previous unsuccessful submissions for that problem, its penalty for that problem is computed as:
inputFormat
The first line contains an integer N
indicating the number of submissions.
Each of the following N
lines contains a submission record in the format:
HH:MM:SS TeamName Problem Result
where HH:MM:SS
is the submission time, TeamName
is a string without spaces, Problem
is a single uppercase letter, and Result
is one of: Accepted
, Time Limit Exceeded
, Memory Limit Exceeded
, Presentation Error
, Wrong Answer
, or Runtime Error
.
Submissions whose time is between 00:00:00
and 04:00:00
(inclusive of 04:00:00) are in the freeze phase. Submissions with time strictly greater than 04:00:00
and up to 05:00:00
are pending.
outputFormat
Output the team names in the order they are announced by the roll-call announcer. Each announcement (including re-announcements) should be printed on a new line.
sample
7
00:10:00 TeamA A Wrong Answer
00:20:00 TeamB B Accepted
00:30:00 TeamA A Accepted
04:10:00 TeamC A Accepted
04:20:00 TeamC C Wrong Answer
04:30:00 TeamC C Accepted
04:40:00 TeamB A Accepted
TeamC
TeamC
TeamA
TeamB
</p>