#P7475. 「C.E.L.U-02」简易输入法
「C.E.L.U-02」简易输入法
Description
This simple input method originally has a dictionary . When the user types, the input method reads a string and an integer from the user. For this string, there are several cases:
Let the number of words such that is a prefix of be .
- When , output the -th after sorting by output count in descending order as the first key and lexicographical order as the second key, and then increase its output count by .
- When , output the last after sorting by output count in descending order as the first key and lexicographical order as the second key, and then increase its output count by .
- When , output
404Error.
Input Format
Line contains an integer , representing that there are originally words in . The initial output count of every originally existing word is .
Lines to each contain a string , representing a word that originally exists in the dictionary.
Line contains an integer , representing that the user performs operations.
Lines to each contain a string and an integer , whose meanings are described above.
Output Format
For each of the user’s operation, output a string.
3
fan
fantasy
father
6
fat 1
fa 1
fan 1
fan 1
fa 1
fant 1
father
father
fan
fan
fan
fantasy
5
uva
usaco
usa
usssu
konjac
11
u 2
u 2
kkk 1
uv 2
us 3
u 4
u 1
u 2
k 1
u 3
usa 1
usaco
usa
404Error
uva
usssu
uva
uva
usa
konjac
usaco
usa
Hint
Sample Explanation
Sample Explanation 1
There is only word with prefix fat, so output father, and increase its output count by .
For prefix fa, the word with the highest output count is father, so output it, and increase its output count by .
For prefix fan, all output counts are , but fan is the smallest in lexicographical order, so output it, and increase its output count by .
For prefix fan, the word with the highest output count is fan, so output fan, and increase its output count by .
For prefix fa, the word with the highest output count is fan, so output it, and increase its output count by .
There is only one word with prefix fant, which is fantasy, so output it, and increase its output count by .
Constraints
| Test ID | ||||
|---|---|---|---|---|
For of the testdata, , and all letters are lowercase letters.
Translated by ChatGPT 5
京公网安备 11011102002149号