#P4291. [HAOI2008] 排名系统
[HAOI2008] 排名系统
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 records are returned.
Input Format
The first line contains an integer denoting the total number of requests. The next lines each contain one request. The specific formats are as follows:
+Name ScoreUpload the latest score record.Namedenotes the player's name, consisting of uppercase English letters, no more than characters.Scoreis a positive integer with at most digits.?NameQuery 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.?IndexReturn up to player names starting from rankIndex.Indexis guaranteed to be valid, i.e., not less than 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 players starting from rankIndex, separated by a space.
20
+ADAM 1000000
+BOB 1000000
+TOM 2000000
+CATHY 10000000
?TOM
?1
+DAM 100000
+BOB 1200000
+ADAM 900000
+FRANK 12340000
+LEO 9000000
+KAINE 9000000
+GRACE 8000000
+WALT 9000000
+SANDY 8000000
+MICK 9000000
+JACK 7320000
?2
?5
?KAINE
2
CATHY TOM ADAM BOB
CATHY LEO KAINE WALT MICK GRACE SANDY JACK TOM BOB
WALT MICK GRACE SANDY JACK TOM BOB ADAM DAM
4
Hint
- For of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号