博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
(用了map) Registration system
阅读量:5870 次
发布时间:2019-06-19

本文共 2063 字,大约阅读时间需要 6 分钟。

 (654123)

 

Registration system
Time Limit:5000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
Submit     

Description

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.

Sample Input

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 
#include
#include
#include
#include
#include
using namespace std;#define N 21000///我也是醉了,map居然有这么大的好处int main(){ int n; while(scanf("%d", &n)!=EOF) { int i; char s[100]; map
a; for(i=0; i
View Code

 

转载于:https://www.cnblogs.com/YY56/p/4850838.html

你可能感兴趣的文章
System V 信号量
查看>>
位运算的三个要点(摘取于韩顺平老师总结)!
查看>>
Sicily 1001. Alphacode
查看>>
Spring(四)Spring之自动装配(autowire)
查看>>
和我一起从0学算法(C语言版)(一)
查看>>
如何实现windows命令提示符的tab补全
查看>>
Java NIO 学习笔记 缓冲区补充
查看>>
SQL Server性能优化(1)使用SET函数
查看>>
MySQL数据库中的中文乱码解决方案。
查看>>
浅谈屏蔽搜索引擎爬虫(蜘蛛)抓取/索引/收录网页的几种思路
查看>>
自动安装lamp架构的shell脚本,版本都比较新,php5.3.8
查看>>
我的友情链接
查看>>
node.js学习笔记之安装详解
查看>>
Saltstack自动化环境部署
查看>>
冒泡排序、插入排序、选择排序的简单了解
查看>>
内存不足报错
查看>>
juniper SSG防火墙与飞塔防火墙配置点到点IPSEC ***
查看>>
Linux网络分析的三大利器
查看>>
决战JavaScript服务端网游开发
查看>>
微软.NET Framework 4.7.x [32+64位]完整包,带静默安装参数!
查看>>