4C - Registration System (Map)

题意描述

A new e-mail service “Berlandesk” is going to be opened in Berland in the near future. The site administration wants to launch their project as soon as possible, that’s why they ask you to help. You’re suggested to implement the prototype of site registration system. The system should work on the following principle.

Each time a new user wants to register, he sends to the system a request with his name. If such a name does not exist in the system database, it is inserted into the database, and the user gets the response OK, confirming the successful registration. If the name already exists in the system database, the system makes up a new user name, sends it to the user as a prompt and also inserts the prompt into the database. The new name is formed by the following rule. Numbers, starting with 1, are appended one after another to name (name1, name2, …), among these numbers the least i is found so that namei does not yet exist in the database.

Input
The first line contains number n (1 ≤ n ≤ 105). The following n lines contain the requests to the system. Each request is a non-empty line, and consists of not more than 32 characters, which are all lowercase Latin letters.

Output
Print n lines, which are system responses to the requests: OK in case of successful registration, or a prompt with a new name, if the requested name is already taken.

Examples
input
4
abacaba
acaba
abacaba
acab

output
OK
OK
abacaba1
OK

input
6
first
first
second
second
third
third

output
OK
first1
OK
second1
OK
third1

思路

一开始以为是字典树的裸题,果断套模板上去,结果发现超内存,于是就考虑使用map,然后就AC了

AC代码

#include<bits/stdc++.h>
#define x first
#define y second
#pragma GCC optimize(2)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3","sse2","sse")
#pragma GCC target("avx","sse4","sse4.1","sse4.2","ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline","fast-math","unroll-loops","no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#define IOS ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef long long LL;
const int N=1e5+1000;
const int INF=0x3f3f3f3f;
const int MOD=998244353;
int main(){
    IOS;
    int n;cin>>n;
    map<string,int> s;
    while(n--){
        string str;cin>>str;
        if(!s[str]){
            cout<<"OK"<<endl;
            s[str]++;
        }else{
            cout<<str<<s[str]++<<endl;
        }
    }
    return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这四个文件都是 ICU (International Components for Unicode) 的 Windows 平台编译版本,其中: - icu4c-73_1-Win64-MSVC2019 是针对 64 位 Windows 平台上使用 MSVC 2019 编译器的版本。 - icu4c-73_1-WinARM64-MSVC2019 是针对 64 位 ARM 架构的 Windows 平台上使用 MSVC 2019 编译器的版本。 - icu4c-73_1-Win64-MSVC2019.zip.asc 是 icu4c-73_1-Win64-MSVC2019 的数字签名文件,用于验证文件的完整性和真实性。 - icu4c-73_1-WinARM64-MSVC2019.zip.asc 是 icu4c-73_1-WinARM64-MSVC2019 的数字签名文件,用于验证文件的完整性和真实性。 如果你的电脑是基于 Intel 或 AMD 架构的 64 位 Windows 操作系统,那么你应该下载 icu4c-73_1-Win64-MSVC2019 这个文件。如果你的电脑是基于 ARM 架构的 64 位 Windows 操作系统,那么你应该下载 icu4c-73_1-WinARM64-MSVC2019 这个文件。 以下是在 Eclipse 中使用 ICU 的步骤: 1. 下载并解压 ICU 的 Windows 平台编译版本,得到一个名为 icu 的文件夹。 2. 在 Eclipse 中创建一个 C++ 项目,例如名为 my_project。 3. 右键点击 my_project 项目,选择 Properties。 4. 在 Properties 窗口中,选择 C/C++ Build - Settings。 5. 在 Tool Settings 标签页中,选择 MinGW C++ Linker - General。 6. 在 Libraries 一栏中,点击 Add 按钮。 7. 在弹出的对话框中,输入 icuuc 和 icui18n,点击 OK。 8. 在 Additional Library Directories 一栏中,点击 Add 按钮。 9. 在弹出的对话框中,输入 ICU 库文件所在的文件夹路径,例如 D:\icu\lib64,点击 OK。 10. 点击 Apply 并关闭 Properties 窗口。 现在,你的 Eclipse 项目应该能够使用 ICU 库了。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值