#P5778. [CTSC2001] GPA 排名系统
[CTSC2001] GPA 排名系统
Problem Description
At present, universities and colleges often use GPA (Grade Point Average) to evaluate students’ academic performance. The traditional ranking method is to compute each student’s average score and rank students based on that average.
However, this ranking method has caused controversy in education and in society, because it has many drawbacks. For different courses, the average score of enrolled students is affected to different degrees by the difficulty of the course and how strict the instructor is. Therefore, this ranking system indirectly encourages students to choose easier courses, because they can get a higher average score with less effort.
To overcome these drawbacks, we need to improve the ranking system.
One improved approach is to add a specific adjustment value to the score of every student who takes course . For example, the score of student in this course is changed to . The goal is that, after adjustment, the average score of this course equals the average of all courses taken by all students who take this course. Perform such an adjustment for every course so that the above condition holds for all courses. This adjustment method can reduce the unfairness of the traditional ranking system to some extent. Your task is to produce the ranking based on the scores of students in one grade of a university for one academic year. Assume that every student takes at least one course.
Input Format
The first line contains two positive integers and , representing the number of students and the number of courses.
The next lines form a matrix. The element in row , column represents the score of student in course . If the student did not take this course, then . Since this approach is only used to obtain a more scientific ranking, the absolute values of the adjusted scores themselves are not meaningful, so the adjusted scores do not have to be within .
Output Format
Output the ranking of these students under the improved approach. Output student indices, one per line.
If, after the adjustment, several students have the same average score (accurate to three digits after the decimal point), then they share the same rank, and they should be output in lexicographical order.
Of course, in many cases, the adjustment above cannot be carried out successfully, meaning the target cannot be achieved. (Therefore, in real problems, we often find an adjustment scheme that is closest to the target in the least-squares sense.) It is also possible that the students’ ranks cannot be determined because the adjustment is not unique. If either of the above two situations occurs, output fail.
4 2
60 -1
70 -1
80 45
-1 65
4
3
2
1
Hint
Sample Explanation
One feasible adjustment method is:
Add to each student’s score in the first course, and add to each student’s score in the second course. The adjusted results are:
70 –1
80 –1
90 80
-1 100
After adjustment, the average score of the first course is: . The average of all courses taken by all students who take the first course is: .
The average score of the second course is: . The average of all courses taken by all students who take the second course is: .
Then, compute each student’s average score and rank them, and you obtain the output result.
Constraints
For all testdata, , , 。
Translated by ChatGPT 5