QOJ.ac

QOJ

実行時間制限: 1 s メモリ制限: 256 MB 満点: 100

#15679. GPA Ranking System

統計

Description

Currently, universities often use GPA (Grade Point Average) to evaluate students' academic performance. The traditional ranking method is to calculate the average grade of each student and use it as the basis for ranking.

However, this ranking method has sparked controversy in the educational community and among various sectors of society because it has many drawbacks. For different courses, the average grade of students taking the course is constrained to varying degrees by the difficulty of the course and the strictness of the instructor. Therefore, such a ranking system implicitly encourages students to choose easier courses, as this allows them to obtain a higher average grade with less effort.

To overcome these drawbacks, we need to make certain improvements to the ranking system.

One improvement scheme is to add a specific correction value $d_i$ to the grade of every student taking the $i$-th course. For example, the grade $G_{ij}$ of student $j$ in that course is modified to $G'_{ij} = G_{ij} + d_i$. The final goal is that after the adjustment, the average grade of that course equals the average grade of all courses taken by all students who took that course. By making such adjustments for every course, the above condition is satisfied for all courses. This adjustment scheme to some extent avoids the unfairness of the traditional ranking system. Your task is to provide the ranking of students based on their grades in a certain academic year at a university. Assume that every student takes at least one course.

Input

The first line contains two positive integers $m$ ($1 \le m \le 500$) and $n$ ($1 \le n \le 100$), representing the number of students and the number of courses, respectively.

The next $m$ lines contain a matrix, where the $j$-th element in the $i$-th row represents the grade $G(i, j)$ of the $i$-th student in the $j$-th course. The input grades are integers between $0$ and $100$. If a student did not take a course, $G(i, j) = -1$. Since this scheme is implemented only to obtain a more scientific ranking, the magnitude of the adjusted grades themselves has no inherent meaning; therefore, the adjusted grades do not need to be between $0$ and $100$.

Output

Output the ranking of these students after applying the improved scheme. Output the student IDs, one per line.

If, after the above adjustment, several students have the same average grade (accurate to three decimal places), they share the same rank and can be output in any order.

In many cases, the above adjustment cannot be performed smoothly, meaning the target of the adjustment cannot be reached. (Therefore, in practical problems, we often obtain an adjustment scheme closest to the target in the least-squares sense.) It is also possible that the ranking of students cannot be determined because the adjustment is not unique. If either of these two situations occurs, output "fail".

Examples

Input 1

4 2
60 -1
70 -1
80 45
-1 65

Output 1

4
3
2
1

Note

One feasible adjustment method is: Add $10$ to the grade of every student in the first course, and add $35$ to the grade of every student in the second course. The situation after adjustment is: $70$ $-1$ $80$ $-1$ $90$ $80$ $-1$ $100$

The average grade of the first course after adjustment is: $(70+80+90)/3 = 80$. The average grade of all courses for all students who took the first course is: $(70+80+90+80)/4 = 80$. The average grade of the second course is: $(80+100)/2 = 90$. The average grade of all courses for all students who took the second course is: $(90+80+100)/3 = 90$. Then, calculate the average grade for each student and rank them to obtain the output result.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.