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

题意:

AC代码:

 #include<iostream>
#include<cstdio>
#include<string>
#include<cstring> using namespace std;
string str[];
int number[]={}; int em(int k)
{
int i;
for(i=k-;i>;i--)
if(str[k]==str[i]){
number[k]=number[i]+;
cout<<str[k]<<number[k]<<endl;
return -;
}
return ;
} int main()
{
int n;
cin>>n;
int i;
for(i=;i<=n;i++)cin>>str[i];
for(i=;i<=n;i++){if(em(i)==)cout<<"OK"<<endl;}
return ;
}

c题 Registration system的更多相关文章

  1. nyoj 991 Registration system (map)

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

  2. ACM Registration system

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

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

  4. CodeForces-4C Registration system

    // Registration system.cpp : 此文件包含 "main" 函数.程序执行将在此处开始并结束. // #include <iostream> # ...

  5. nyoj Registration system

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

  6. (用了map) Registration system

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93241#problem/C (654123) http://codeforces.com ...

  7. codeforces Registration system

     Registration system A new e-mail service "Berlandesk" is going to be opened in Berland in ...

  8. Codeforces Beta Round #4 (Div. 2 Only) C. Registration system【裸hash/map】

    C. Registration system time limit per test 5 seconds memory limit per test 64 megabytes input standa ...

  9. Registration system

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2 描写叙述 A new e-mail service "Berlandesk&q ...

随机推荐

  1. NMON监控工具

    工具可将服务器的系统资源耗用情况收集起来并输出一个特定的文件,并可利用 excel 分析工具nmonanalyser进行数据的统计分析.并且,nmon运行不会占用过多的系统资源,通常情况下CPU利用率 ...

  2. 如何查看centos系统版本

    [root@LAMP1 config]# cat /proc/version Linux version 2.6.32-279.el6.x86_64 (mockbuild@c6b9.bsys.dev. ...

  3. F9 excel上传

    1 在前台制定文件上传按钮 <div id="dataImport" class="mini-webuploader" pickerText=" ...

  4. Pelican主题配置:elegant

    简介 elegant是Mac风格的优秀主题,简单,专注文章本身. A responsive, minimal, and stylish theme for Pelican:https://github ...

  5. matlab里textread出现错误“Trouble reading floating point number from file (row 1, field 1)”

    matlab里textread出现错误“Trouble reading floating point number from file (row 1, field 1)” 解决办法:traindata ...

  6. web.xml Attribute "xmlns" was already specified for element "web-app"

    报错信息:Attribute "xmlns" was already specified for element "web-app" 由于项目的重命名,出现了x ...

  7. 使用OllyDbg从零开始Cracking CHM

    需要的小伙伴拿走,百度云链接:https://pan.baidu.com/s/1pLJa5dh.另有一些视频资料,太多,需要的可以留言.

  8. MySQL-Front 出现“程序注册时间到期 程序将被限制模式下运行”解决方式

    MySQL-Front 出现“程序注册时间到期 程序将被限制模式下运行”解决方式 在用mysql-front的时候遇到显示:程序注册时间到期程序将被限制模式下运行.可以在“帮助”菜单下的点“登记”-- ...

  9. Struct和Class的区别(转载)

    转载来源:http://blog.sina.com.cn/s/blog_48f587a80100k630.html C++中的struct对C中的struct进行了扩充,它已经不再只是一个包含不同数据 ...

  10. Finish and error to: Error Domain=NSURLErrorDomain Code=-1001 "请求超时。

    错误显示:Finish and error to: Error Domain=NSURLErrorDomain Code=-1001 "请求超时." UserInfo={NSUnd ...