#P6363. [传智杯 #2 初赛] 软件工程实习

[传智杯 #2 初赛] 软件工程实习

Description

A university’s required course “Software Engineering” is divided into a theory part and a practice part. The theory part is taught by professors at the university. The practice part is led by a third-party company: students need to learn HTML, css, JavaScript, vue, Python, django, and other technologies by themselves within five weeks, and form teams to complete a real internet business application.

There are n(0n1000)n(0\le n \le 1000) students taking this course. They are divided into no more than 2626 teams, and each team is represented by a letter from A to Z. Each team completes a project and, as a team, gives scores to all teams (including their own team). The scores are integers from 00 to 100100.

To calm students’ dissatisfaction caused by many issues of this course (such as too much workload, overly tight schedule, unfair assessment method, etc.), the teacher decides to use a method that “looks” fair to determine each team’s project score:

For a given team, first compute the average of all scores given to this team by all teams (including itself). Then remove the scores that differ from this average by more than 1515 points (it is guaranteed that not all scores will be removed). Finally, compute the average of the remaining scores, round it to the nearest integer, and use it as the team’s project score.

For each student, we already know their team code and theory score (also an integer from 00 to 100100). The student’s final score is 60%60\% of the theory score plus 40%40\% of the project score of their team, then rounded to the nearest integer.

Now the teacher wants to know the ranking of all students’ scores. Please output each student’s score and their team, in descending order of final score.

Input Format

The first line contains two integers nn and kk, representing the number of students and the number of teams.

The next nn lines each contain an integer sis_i and an uppercase letter cic_i, representing the theory score of the ii-th student and their team ID. It is guaranteed that the team IDs are among the consecutive kk letters starting from A.

The next kk lines each contain kk integers. The integer ai,ja_{i,j} in row ii and column jj represents the score given by team ii to team jj. When i=ji=j, it is the self-score.

Output Format

Output nn lines as the answer. Students with higher scores should be output first. If scores are the same, students with a smaller team ID should be output first. For each line, first output the student’s score, then output the uppercase letter representing their team ID.

6 3
70 A
80 A
65 B
95 B
85 C
90 C
70 90 100
95 88 85
30 47 100
93 B
92 C
89 C
76 A
75 B
70 A

Hint

The scores received by team A are 70,95,3070,95,30. Their average is 6565, so 95,3095,30 are removed as invalid scores. Therefore, team A’s project score is 7070.
The scores received by team B are 90,88,4790,88,47. Their average is 7575, so 4747 is removed as an invalid score. Therefore, team B’s project score is 8989.
The scores received by team C are 100,85,100100,85,100. Their average is 9595, so no score is removed. Therefore, team C’s project score is 9595.

Translated by ChatGPT 5