#P4291. [HAOI2008] 排名系统

    ID: 3237 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>模拟字符串2008河南各省省选平衡树

[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 1010 records are returned.

Input Format

The first line contains an integer n(10n250000)n(10\le n\le250000) denoting the total number of requests. The next nn 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 1010 characters. Score is a positive integer with at most 88 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 1010 player names starting from rank Index. Index is guaranteed to be valid, i.e., not less than 11 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 1010 players starting from rank Index, 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 20%20\% of the testdata, N100N\le100.
  • For 100%100\% of the testdata, N2.5×105N\le2.5\times10^5.

Translated by ChatGPT 5