Ranking

Special Judge Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

      In this problem you are asked to implement the ranking system for a series of programming contests. Each contest runs using standard ACM ICPC rules, each run is judged and either accepted, or rejected. For each solved problem the penalty time is calculated as the time of the first accepted run in minutes plus twenty minutes for each unsuccessful run before the first successful run. For problems that are not solved no penalty time is considered. The teams are first ranked by the number of solved problems, next by the penalty time. Each team gets the highest possible rank, that is, if two or more teams have the same number of solved problems and the same penalty times, they all share the same place, highest from the range they occupy. So, for example, there can be two teams sharing the first place, followed by the third place team, and so on.
      The ranking of each team for the series of the contests is calculated as follows. Let Pij be the number of problems solved by j-th team in the i-th contest. Let PMbe the maximal number of problems solved by some team in the i-th contest. The raw score of the j -th team for this contest is RSij = Pij/PMi if PMi > 0 and RSij = 0 if PMi = 0. Let Ki be the number of teams take part in the i-th contest. Calculate Ai and Bi , satisfying equations 

      If the j -th team is ranked Rij in the i-th contest, its score for this contest is

      If the j -th team took part in Cj > 0 contests, its total score is

      in the other case its total score is Tj = 0.
      Given the description of several contests, your task is for each team to calculate its total score.

Input

      The first line of the input file contains N — the number of teams (2 ≤ N ≤ 100), next N lines contain team names, length of each name does not exceed 100 characters. Let teams be numbered as they are given in the input file, starting from one. 

      Next line contains M — the number of contests in a series (1 ≤ M ≤ 20). The descriptions of the contests follow. The first line of the contest descrption contains Ki — the number of teams that took part in this contest (2 ≤ Ki ≤ N ) and the numbers of these teams. Next line contains PNi— the number of problems in the contest (1 ≤ PNi ≤ 26). Problems are identified using capital letters of the English alphabet, starting from ‘A’. Next line contains RNi — the number of runs in the contest (0 ≤ RNi ≤ 10 000). Next RNlines describe runs, each run description consists of four items, adjacent items are separated from each other by exactly one space. The items are: the number of the team, the letter of the problem, the time of the run in minutes and character ‘ +’ if the run is accepted, or ‘-’ if it is rejected. Runs are given in the order they were made, in particular run times are non-decreasing. Times
are positive integers that do not exceed 300.

Output

      Output N lines — the teams in the non-increasing order of their total score. In case of equal total score, teams may be output in arbitary order. Print score aligned, so that there is exactly one space between the longest team name and the leftmost digit of the score, and all decimal points are in the same column. Print exactly four digits after the decimal point.

Sample Input

4
MosCow SU
ThreeThreads
SPb IMHO
SPb FLY
3
3  1 2 3
5
10
1 A 30 +
1 B 80 +
2 A 85 -
2 C 90 +
1 E 101 +
3 A 130 -
3 A 140 +
1 D 150 +
3 D 280 +
3 E 299 +
2  2 3
2
3
2 A 160 +
2 B 245 +
3 A 280 +
3  1 3 4
4
6
1 A 50 +
3 A 50 +
1 A 155 -
3 A 160 +
1 B 180 -
4 A 200 -

Sample Output

MosCow SU    2.0000
SPb IMHO     1.1667
ThreeThreads 1.1250
SPb FLY      0.0000

Source

Andrew Stankevich Contest 4

Manager

Information
Solved Number32
Submit Number127
Problem Tags
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel