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. 通过学习制作长微博工具来了解水印的制作,及EditText中的内容在图片中换行显示

    长微博工具非常有用,140字的要求可能阻止你写更多的内容,于是长微博工具应运而生,虽然网上有很多长微博工具,但是我都不是很满意,所以自己想做一个,通过做这个长微博工具,我学习到了很多东西,有两个难点, ...

  2. MySQL隐式转换测试

      Preface       There're various data type in MySQL such as number,string,date,time,lob,etc.The data ...

  3. Windows环境下,python webdriver环境搭建

    最近刚开始学习selenium,这是我从虫师的<selenium2自动测试实战--基于Python语言>这本书上学到搭建环境的步骤,里面有加上我的一些总结,希望对大家有所帮助!   准备工 ...

  4. ironic的自动化脚本

    # -*- coding:utf-8 -*- import json import subprocess import os import time import random trunk_start ...

  5. Leetcode 658.找到K个最接近的元素

    找到k个最接近的元素 给定一个排序好的数组,两个整数 k 和 x,从数组中找到最靠近 x(两数之差最小)的 k 个数.返回的结果必须要是按升序排好的.如果有两个数与 x 的差值一样,优先选择数值较小的 ...

  6. springbootday06 mysql

    一.MySql 1. 数据库概述 数据库( Database )是按照数据结构来组织.存储和管理数据的仓库 . 数据按照特定的格式存储起来,用户可以通过SQL (Structured Query La ...

  7. solr集群搭建(复制)

    Solr集群的搭建以及使用(内涵zookeeper集群的搭建指南) 1   什么是SolrCloud SolrCloud(solr 云)是Solr提供的分布式搜索方案,当你需要大规模,容错,分布式索引 ...

  8. Spring框架jar包分类(转)

    转自:http://www.cnblogs.com/JSONBEAN/p/6364038.html 长期以来都在写SSM框架的项目,却未能深入理解框架的搭建原理,而只是浅薄的理解前辈的架构,然后不断套 ...

  9. aFlex脚本入门

    aFlex脚本入门 来源:http://blog.51cto.com/virtualadc/599194 来源:http://blog.51cto.com/virtualadc/624219 对于A1 ...

  10. 【BZOJ1179】[Apio2009]Atm (tarjan+SPFA)

    显而易见的tarjan+spfa...不解释了 ; type edgetype=record toward,next:longint; end; var edge1,edge2:..maxn] of ...