银行账户AI (CI翻译)
Problem Statement
题目描述
AI (CI翻译)In the backyard of Kowasugi Bank, ghosts are growing pumpkins. You have decided to open bank accounts for the pumpkins.
AI (CI翻译)在 Kowasugi 银行的后院里,幽灵们正在种南瓜。你决定为这些南瓜开设银行账户。
When a bank account for a pumpkin is opened, it is assigned one name and one ID. The ID is chosen as the smallest positive integer that is not yet used as an ID.
为南瓜开设银行账户时,会为该账户分配一个名称和一个 ID。ID 取尚未被用作 ID 的最小正整数。AI (CI翻译)
Initially, no bank accounts for pumpkins have been opened. The following event occurs $Q$ times; process them in order.
最初,没有为任何南瓜开设银行账户。以下事件会发生 $Q$ 次,请按顺序处理。AI (CI翻译)
- A pumpkin comes and introduces itself with the name
$s$. - If there is an account assigned the name
$s$, print its ID.- If there is no account assigned the name
$s$, open one new account with the name$s$and print its ID.
- If there is no account assigned the name
- 一个南瓜前来,并自我介绍说它的名字是
$s$。 - 如果存在名称为
$s$的账户,输出其 ID。- 如果不存在名称为
$s$的账户,则开设一个名称为$s$的新账户,并输出其 ID。
- 如果不存在名称为
Constraints
约束条件
AI (CI翻译)$Q$is an integer between$1$and$2 \times 10^5$, inclusive.- In each event,
$s$is a string of length between$1$and$10$, inclusive, consisting of lowercase English letters.
$Q$是$1$到$2 \times 10^5$之间的整数(包含两端)。- 在每次事件中,
$s$是一个长度为$1$到$10$(包含两端)、仅由小写英文字母组成的字符串。
Input
输入格式
AI (CI翻译)The input is given from Standard Input in the following format:
输入通过标准输入以如下格式给出:AI (CI翻译)
Q
\mathrm{query}_1
\vdots
\mathrm{query}_Q
Q
\mathrm{query}_1
\vdots
\mathrm{query}_QAI (CI翻译)
$\mathrm{query}_i$ represents the $i$-th event and is given in the following format:
$\mathrm{query}_i$ 表示第 $i$ 次事件,以如下格式给出:AI (CI翻译)
s
sAI (CI翻译)
Output
输出格式
AI (CI翻译)Print $Q$ lines. The $i$-th line should contain the value to be printed in the $i$-th event.
输出 $Q$ 行。第 $i$ 行应包含第 $i$ 次事件中应输出的值。AI (CI翻译)
样例
8
pumpkin
hobak
pompoen
hobak
pumpkin
boga
boga
hobak
1
2
3
2
1
4
4
2
7
joayo
joayo
joayo
joayo
joayo
joayo
joayo
1
1
1
1
1
1
1
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。