AT_abc481_c.Bank Accounts
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
In the backyard of Kowasugi Bank, ghosts are growing pumpkins. You have decided to open bank accounts for the pumpkins.
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.
Initially, no bank accounts for pumpkins have been opened. The following event occurs Q times; process them in order.
- 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.
在小笠银行的后院里,幽灵们正在种植南瓜。你决定为这些南瓜开设银行账户。
当为一个南瓜开设银行账户时,会为其分配一个名称和一个 ID。ID 被选为尚未被用作 ID 的最小正整数。
初始时,尚未为任何南瓜开设银行账户。接下来将按顺序发生 Q 次以下事件,请依次处理:
- 一个南瓜到来,并以名称 s 进行自我介绍。
- 如果已有账户被分配了名称 s,则输出该账户的 ID;
- 如果没有账户被分配名称 s,则为该名称 s 新建一个账户,并输出其 ID。
输入格式
The input is given from Standard Input in the following format:
Q
query1
⋮
queryQ
queryi represents the i-th event and is given in the following format:
s
输入从标准输入中以如下格式给出:
Q
query1
⋮
queryQ
queryi 表示第 i 个事件,其格式如下:
s
输出格式
Print Q lines. The i-th line should contain the value to be printed in the i-th event.
输出 Q 行。第 i 行应包含第 i 个事件中要输出的值。
输入输出样例
输入#1
8 pumpkin hobak pompoen hobak pumpkin boga boga hobak
输出#1
1 2 3 2 1 4 4 2
输入#2
7 joayo joayo joayo joayo joayo joayo joayo
输出#2
1 1 1 1 1 1 1
说明/提示
Sample 1 Explanation:
The events proceed as follows.
- In the 1-st event, a new account with the name
pumpkinand ID 1 is opened. - In the 2-nd event, a new account with the name
hobakand ID 2 is opened. - In the 3-rd event, a new account with the name
pompoenand ID 3 is opened. - In the 4-th event, an account with the name
hobakalready exists, and its ID is 2. - In the 5-th event, an account with the name
pumpkinalready exists, and its ID is 1. - In the 6-th event, a new account with the name
bogaand ID 4 is opened. - In the 7-th event, an account with the name
bogaalready exists, and its ID is 4. - In the 8-th event, an account with the name
hobakalready exists, and its ID is 2.
Constraints
- Q is an integer between 1 and 2×105, inclusive.
- In each event, s is a string of length between 1 and 10, inclusive, consisting of lowercase English letters.
样例 1 解释:
事件按以下顺序发生。
- 在第 1 个事件中,创建一个名为
pumpkin、ID 为 1 的新账户。 - 在第 2 个事件中,创建一个名为
hobak、ID 为 2 的新账户。 - 在第 3 个事件中,创建一个名为
pompoen、ID 为 3 的新账户。 - 在第 4 个事件中,名称为
hobak的账户已存在,其 ID 为 2。 - 在第 5 个事件中,名称为
pumpkin的账户已存在,其 ID 为 1。 - 在第 6 个事件中,创建一个名为
boga、ID 为 4 的新账户。 - 在第 7 个事件中,名称为
boga的账户已存在,其 ID 为 4。 - 在第 8 个事件中,名称为
hobak的账户已存在,其 ID 为 2。
约束条件
- Q 是一个介于 1 和 2×105(含)之间的整数。
- 在每个事件中,s 是一个长度介于 1 和 10(含)之间的字符串,且仅由小写英文字母组成。
输入解题思路,AI测评打分。不知道怎么写?