There are so many submissions during this contest. Coach Pang can not determine which team is the winner. Could you help him to print the score board?
As we all know, the contest executes by the teams submit codes for some problems. Simply, we assume there are three kinds of results for every submission.
ERROR There was something wrong. The team didn’t solve the problem but won’t get any penalty.
NO Sorry, the code was not right. The team didn’t solve the problem.
YES Yeah, AC. The team solved the problem.
To make the contest more exciting, we set a time called frozen time. If one team doesn’t solve one of the problems before the frozen time and submits at least one submission on this problem after or exactly at the frozen time, this problem of this team is called frozen. For different team, the frozen problems will be different. For the frozen problems, the score board will only show how many submissions the team has been submitted but won’t show the result of the submissions.
The rank is determined by the following factors. Remember, we only consider the unfrozen problems. The frozen problems will be ignored. The following factors are ordered with the priority from high to low.
Solved the team who solves more problems will place higher.
Penalty the team who gets less penalty time will place higher. Only solved problems will give penalty time. Every solved problem will give T + 20X penalty time. T is the time of the first YES, X is the number of NOs before the first YES.
Last Solved the team who solved their last problem earlier will place higher. If there is a tie, we compare their second last problems, then their third last problems, etc.
Name The team whose name comes later in lexicographical order will place higher.
At the end of the contest, the score board will be unfrozen. First, choose the team which has frozen problems with the lowest rank. Then choose one frozen problem of this team. If the team has multiple frozen problems, choose their first frozen problem in alphabetic order. Then show the result of the problem, recalculate the rank, change the score board and make the problem unfrozen for this team. Repeat this procedure until no teams have frozen problems. Then we get the final score board.
Please help Coach Pang to print the initial score board, the final score board and the process of the unfreeze procedure.