Codeforces Beta Round #4 (Div. 2 Only) C. Registration system【裸hash/map】
5 seconds
64 megabytes
standard input
standard output
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.
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.
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.
4
abacaba
acaba
abacaba
acab
OK
OK
abacaba1
OK
6
first
first
second
second
third
third
OK
first1
OK
second1
OK
third1
【代码】:
#include<bits/stdc++.h>
using namespace std;
int n,m,cnt;
string s;
map<string,int> mp;
int main()
{
while(cin>>n)
{
while(n--)
{
cin>>s;
mp[s]++;
if(mp[s]==)
puts("OK");
else
cout<<s<<mp[s]-<<endl;
}
}
return ;
}
STL
Codeforces Beta Round #4 (Div. 2 Only) C. Registration system【裸hash/map】的更多相关文章
- Codeforces Beta Round #4 (Div. 2 Only) C. Registration system hash
C. Registration system Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/problemset ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
随机推荐
- LDAP操作的两种方案
最近由于项目需要研究了一下LDAP相关知识,感觉对没接触过的人来说还是有点坑的,所以记录下来给大家分享. 由于是第一次接触,就在网上搜了一些相关的文章,照着示例代码测试,却怎么也连不上LDAP服务器, ...
- 从事IT业一个8年老兵转行前的自我总结2——从《易经》说开来
近些年一直在读<易经>,收获颇多.以前看不贯的人或物现在可以淡然看定,以前看不开的一些事现在也安然放下,以前看不透的某些事现在也都可看透八九不离十. 古人云:不读<易>不可为将 ...
- 《数据结构》C++代码 邻接表与邻接矩阵
上一篇“BFS与DFS”写完,突然意识到这个可能偏离了“数据结构”的主题,所以回来介绍一下图的存储:邻接表和邻接矩阵. 存图有两种方式,邻接矩阵严格说就是一个bool型的二维数组,map[i][j]表 ...
- 关于在虚拟机上安装iOS所遇到的问题
先配一张成功的图片: 要想实现上图所示的,就要安装 unlocker206, 安装完unlocker206 不用改里面的内容!!!看到**经验上说还要改内容,结果我试了很多次,根本不行,其实问题不在改 ...
- ADB连接手机遇到的问题:list of devices attached
今天工作时想尝试一下使用ADB无线连接手机,结果遇到了下面这样的问题,浪费了几十分钟的时间,挺闹心的,因此想分享出来... 首先 第一步:使用USB数据线连接手机,手机弹出选项时,选择仅充电,然后wi ...
- 抽象类和虚方法、base关键字
微软官方文档:https://docs.microsoft.com/zh-cn/dotnet/csharp/programming-guide/classes-and-structs/abstract ...
- Linux大小端模式转换函数
转自 http://www.cnblogs.com/kungfupanda/archive/2013/04/24/3040785.html 不同机器内部对变量的字节存储顺序不同,有的采用大端模式(bi ...
- STL之list使用简介
构造函数 list<int> c0; //空链表 list<); //建一个含三个默认值是0的元素的链表 list<,); //建一个含五个元素的链表,值都是2 list< ...
- 在python中如何比较两个float类型的数据是否相等
奇怪的现象 前几天跟同事聊起来,在计算机内部float比较是很坑爹的事情.比方说,0.1+0.2得到的结果竟然不是0.3? >>> 0.1+0.2 0.300000000000000 ...
- 第二阶段团队冲刺-seven
昨天: 合并程序(添加打印txt). 今天: 整体调试程序继续优化. 遇到的问题: 解决前两天的问题.