C. Registration system
time limit per test

5 seconds

memory limit per test

64 megabytes

input

standard input

output

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.

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

【代码】:

#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】的更多相关文章

  1. 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 ...

  2. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  5. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  8. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  9. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. react事件处理及动态样式添加

    多数据的事件绑定,循环数据来进行绑定.如下方式就是循环绑定事件的基本代码: this.state.lists.map(function(value,index,array){//代码片段}.bind( ...

  2. 《Cracking the Coding Interview》——第2章:链表——题目2

    2014-03-18 02:24 题目:给定一个单链表,找出倒数第K个节点. 解法:让一个指针先走K步,然后俩指针一起走到尽头.当然也可以先走到尽头数出链表的长度,然后第二次少走K步.其实耗费的工夫是 ...

  3. 四 Android Capabilities讲解

    本文转自:http://www.cnblogs.com/sundalian/p/5629429.html Android Capabilities讲解   1.Capabilities介绍 可以看下之 ...

  4. 百度webuploader上传 1

    百度webupload网址:http://fex.baidu.com/webuploader/ 引入js和css <script src="../../Content/webuploa ...

  5. Pacemaker、corosync

    pacemaker详细介绍: http://blog.51cto.com/freeloda/1274533 corosync详细介绍: http://blog.51cto.com/freeloda/1 ...

  6. 解决LaTex中插入Visio画图有多余边框的问题

    这里的Visio画图是指Visio另存为或导出的PDF格式图片.就目前而言,Visio另存为的EPS格式的图片均可使用PDF格式代替. 问题描述 这里以Visio中画一个矩形为例,如上图所示. 我们为 ...

  7. [部署开发环境][1 vagrant] vagrant部署开发环境--安装vagrant

    # 安装教程 # 安装vagrant 教程 # 准备 - windows操作系统 - VirtualBox---Win, - vagrant_1.9.3.msi - 镜像文件https://atlas ...

  8. A Neural Algorithm of Artistic Style

    本系列文章由 @yhl_leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/53931536 1. 资源 Paper: ...

  9. ActiveX 控件和 Web 浏览器加载项

    百度ActiveX的概念. 如何从零开始写一个 Chrome 扩展 360极速浏览器应用开发平台.

  10. jquery select chosen禁用某一项option

    $("#tbParBudCode").chosen().change(function () { $("#tbParBudCode option[value='" ...