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 QQ times; process them in order.

  • A pumpkin comes and introduces itself with the name ss.
    • If there is an account assigned the name ss, print its ID.
    • If there is no account assigned the name ss, open one new account with the name ss and print its ID.

在小笠银行的后院里,幽灵们正在种植南瓜。你决定为这些南瓜开设银行账户。

当为一个南瓜开设银行账户时,会为其分配一个名称和一个 ID。ID 被选为尚未被用作 ID 的最小正整数。

初始时,尚未为任何南瓜开设银行账户。接下来将按顺序发生 QQ 次以下事件,请依次处理:

  • 一个南瓜到来,并以名称 ss 进行自我介绍。
    • 如果已有账户被分配了名称 ss,则输出该账户的 ID;
    • 如果没有账户被分配名称 ss,则为该名称 ss 新建一个账户,并输出其 ID。

输入格式

The input is given from Standard Input in the following format:

QQ
query1\mathrm{query}_1
⋮\vdots
queryQ\mathrm{query}_Q

queryi\mathrm{query}_i represents the ii-th event and is given in the following format:

ss

输入从标准输入中以如下格式给出:

QQ
query1\mathrm{query}_1
⋮\vdots
queryQ\mathrm{query}_Q

queryi\mathrm{query}_i 表示第 ii 个事件,其格式如下:

ss

输出格式

Print QQ lines. The ii-th line should contain the value to be printed in the ii-th event.

输出 QQ 行。第 ii 行应包含第 ii 个事件中要输出的值。

输入输出样例

  • 输入#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 11-st event, a new account with the name pumpkin and ID 11 is opened.
  • In the 22-nd event, a new account with the name hobak and ID 22 is opened.
  • In the 33-rd event, a new account with the name pompoen and ID 33 is opened.
  • In the 44-th event, an account with the name hobak already exists, and its ID is 22.
  • In the 55-th event, an account with the name pumpkin already exists, and its ID is 11.
  • In the 66-th event, a new account with the name boga and ID 44 is opened.
  • In the 77-th event, an account with the name boga already exists, and its ID is 44.
  • In the 88-th event, an account with the name hobak already exists, and its ID is 22.

Constraints

  • QQ is an integer between 11 and 2×1052 \times 10^5, inclusive.
  • In each event, ss is a string of length between 11 and 1010, inclusive, consisting of lowercase English letters.

样例 1 解释:
事件按以下顺序发生。

  • 在第 11 个事件中,创建一个名为 pumpkin、ID 为 11 的新账户。
  • 在第 22 个事件中,创建一个名为 hobak、ID 为 22 的新账户。
  • 在第 33 个事件中,创建一个名为 pompoen、ID 为 33 的新账户。
  • 在第 44 个事件中,名称为 hobak 的账户已存在,其 ID 为 22。
  • 在第 55 个事件中,名称为 pumpkin 的账户已存在,其 ID 为 11。
  • 在第 66 个事件中,创建一个名为 boga、ID 为 44 的新账户。
  • 在第 77 个事件中,名称为 boga 的账户已存在,其 ID 为 44。
  • 在第 88 个事件中,名称为 hobak 的账户已存在,其 ID 为 22。

约束条件

  • QQ 是一个介于 11 和 2×1052 \times 10^5(含)之间的整数。
  • 在每个事件中,ss 是一个长度介于 11 和 1010(含)之间的字符串,且仅由小写英文字母组成。

输入解题思路,AI测评打分。不知道怎么写?

首页