#P2584. GameZ Ranking System

    ID: 15853 Type: Default 1000ms 256MiB

GameZ Ranking System

GameZ Ranking System

GameZ has launched a website for their latest game where players around the world can upload their scores and view their global rankings. A higher score gives a better ranking, and when players have the same score, the one who uploaded first is ranked higher. When a player uploads a new score, any previous record is replaced.

The ranking system must handle three types of queries:

  1. Upload Query:
    Format: 1 username score
    Description: Upload a new score for username. This replaces any previous score record for the same user.
  2. Player Query:
    Format: 2 username
    Description: Output the current ranking (1-indexed) of username. If the player does not exist, output 0.
  3. Range Query:
    Format: 3 L R
    Description: Return the ranking records from rank L to rank R. Note: Even if more than 10 records exist in the range, only the first 10 records will be returned. Each record is output on a new line in the format username score.

Ranking is determined using the following rule in \( \LaTeX \) format:

\( \text{Order} = \{ (score, time) \ | \ score\text{ in descending order, and if } score \text{ is equal then } time \text{ in ascending order}\} \)

inputFormat

The first line contains an integer Q, the number of queries.

Each of the next Q lines contains a query in one of the following formats:

  • 1 username score
  • 2 username
  • 3 L R

outputFormat

For each query, output as follows:

  • Type 1 queries produce no output.
  • Type 2 queries output a single integer on a new line: the 1-indexed ranking of username (or 0 if the player does not exist).
  • Type 3 queries output the ranking records from rank L to rank R (only up to 10 records are printed) with each record on a new line in the format username score.

sample

6
1 Alice 100
1 Bob 200
2 Alice
3 1 2
1 Alice 250
2 Alice
2

Bob 200 Alice 100 1

</p>