#K76537. Player Ranking
Player Ranking
Player Ranking
You are given several test cases. For each test case, you are provided with a list of players along with their scores. Your task is to rank the players in descending order based on their scores. If two players have the same score, they should be ranked in ascending lexicographical order of their names.
Mathematically, for each test case with players represented as pairs \((name, score)\), you need to sort the list such that for any two players \(A\) and \(B\), \(A\) comes before \(B\) if and only if either \(score_A > score_B\) or \(score_A = score_B\) and \(name_A < name_B\) (in lexicographical order).
inputFormat
The input is read from standard input. The first line contains an integer (T), representing the number of test cases. For each test case:
- The first line contains an integer (n), denoting the number of players.
- Each of the following (n) lines contains a player's name (a string without spaces) and score (an integer), separated by a single space.
Note: When (n = 0), there are no subsequent lines for that test case.
outputFormat
For each test case, output a single line to standard output containing the ranked list of player names separated by a single space. If a test case has no players, output an empty line.## sample
1
3
Alice 100
Bob 200
Charlie 150
Bob Charlie Alice
</p>