Deanonymizing Grades X41559


Statement
 

pdf   zip

html

We are to receive a list of grades for several courses and students. However, for privacy, they are provided anonymized: students will appear there identified by an anonymous numeric code. Separately, we have as well the code corresponding to each student’s name (assumed a single word for simplicity). We want to list the plain names and codes together with the average grade of each student. The list must have a line per student, start with the student’s name, and then indicate the code and the average grade; and must be ordered according to the numeric code.

Input

First comes alone in a line the number of students n. Then come n pairs, each in a line, consisting of a student name and a numeric code, separated by a space. It is guaranteed that all the codes are different, and so are as well the names. Then comes the total number of grades m followed by m lines with grades: each line has, first, the numeric code of some student, then the mark of the student (a float) for one of the evaluable acivities of some course, also separated by a space.

Output

Output must not include students with no grades. As for the rest, output consists of as many lines as students. Each line starts with the name of the student, then the numeric code corresponding to the student, and the average grade of the student. Print all floats rounded to two decimal places. The lines must come ordered according to the numeric code. Inside each line, everything must come separated by single spaces. There should not be trailing spaces.

Public test cases
  • Input

    10
    Finley 2150
    Skyler 154
    Lennon 1159
    Azariah 156
    Sidney 2151 
    Denver 158
    Campbell 1152
    Jaidyn 3153
    Brighton 4157
    Kylar 155
    25
    2150 6.6
    154 7.3
    1159 5.0
    156 8.8
    2151 7.5
    158 4.1
    1152 2.3
    3153 9.3
    4157 6.7
    155 7.7
    2150 9.2
    154 8.7
    1159 8.5
    156 5.0
    2151 6.7
    158 5.6
    1152 8.2
    3153 7.7
    4157 8.9
    155 5.1
    154 9.9
    1159 9.1
    3153 4.4
    4157 8.9 
    155 9.9

    Output

    Skyler 154 8.63
    Kylar 155 7.57
    Azariah 156 6.90
    Denver 158 4.85
    Campbell 1152 5.25
    Lennon 1159 7.53
    Finley 2150 7.90
    Sidney 2151 7.10
    Jaidyn 3153 7.13
    Brighton 4157 8.17
    
  • Information
    Author
    José Luis Balcázar
    Language
    English
    Official solutions
    Python
    User solutions
    Python