P4291 [HAOI2008] Ranking System
Description
A ranking system typically needs to handle three types of requests: uploading a new score record, querying a player's current rank, and returning the ranking records within a segment. When a player uploads their latest score record, their previous score record is deleted. To reduce server load, when returning a segment of the ranking, at most $10$ records are returned.
Input Format
The first line contains an integer $n(10\le n\le250000)$ denoting the total number of requests. The next $n$ lines each contain one request. The specific formats are as follows:
- `+Name Score` Upload the latest score record. `Name` denotes the player's name, consisting of uppercase English letters, no more than $10$ characters. `Score` is a positive integer with at most $8$ digits.
- `?Name` Query the player's rank. This player's score record must have been uploaded earlier. If two players have the same score, the one who obtained that score earlier ranks ahead.
- `?Index` Return up to $10$ player names starting from rank `Index`. `Index` is guaranteed to be valid, i.e., not less than $1$ and not greater than the current number of players with records.
Output Format
- For requests of the form `?Name`, output a single integer denoting that player's current rank.
- For requests of the form `?Index`, output in one line the names of up to $10$ players starting from rank `Index`, separated by a space.
Explanation/Hint
- For $20\%$ of the testdata, $N\le100$.
- For $100\%$ of the testdata, $N\le2.5\times10^5$.
Translated by ChatGPT 5