League
InterviewTime limit1sMemory limit128 MB
Given every match result in a round-robin soccer league, compute each team's total points and print its rank, where tied teams share the best rank.
- Level
Easy2 of 10
- Topics
- Implementation, Array, Sorting, Simulation
- Solved
- No attempts yet
Problem
A soccer league has teams, numbered from to . In this league every pair of distinct teams plays exactly once, so a total of matches are played.
In each match, the team that scores more goals wins. Points are awarded as follows:
- Winning team: points
- Losing team: points
- Draw: each team gets point
The league standings are determined solely by the total number of points each team has earned; goal difference is not considered. Teams with the same total share the same rank, and that rank is the highest possible value. In other words, a team's rank equals (the number of teams with strictly more points) .
For example, suppose teams take part in the league, so matches are played. Suppose the results are as in the table below. In each cell, the number to the left of the hyphen (-) is the score of the team in that row, and the number to the right is the score of the team in that column.
Team 2 has the most points and is ranked st. Team 1 and Team 4 have the next-highest and equal totals, so both are ranked nd. Team 3 has the fewest points and is ranked th.
Given the results of all matches, write a program that computes the rank of each team.
Input
The first line contains the number of teams ().
Each of the next lines contains the result of one match as four integers , meaning that in the match between team and team , team scored points and team scored points. and are always different, and the result of the same match is never given more than once.
Output
Print lines. The -th line contains the rank of team .