ACM Registration system
Registration system
- 描述
-
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 1000 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#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std; int main(){
int n;
cin >> n;
map<string,int> nameMap;
while(n--){
string str;
cin >>str;
if(nameMap.find(str)==nameMap.end()){
nameMap.insert(make_pair(str,));
cout<<"OK"<<endl;
}else{
nameMap[str]++;
cout<<str<<nameMap[str]<<endl;
}
}
}
ACM Registration system的更多相关文章
- (用了map) Registration system
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93241#problem/C (654123) http://codeforces.com ...
- 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 ...
- c题 Registration system
Description A new e-mail service "Berlandesk" is going to be opened in Berland in the near ...
- CodeForces-4C Registration system
// Registration system.cpp : 此文件包含 "main" 函数.程序执行将在此处开始并结束. // #include <iostream> # ...
- nyoj Registration system
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
- codeforces Registration system
Registration system A new e-mail service "Berlandesk" is going to be opened in Berland in ...
- 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 ...
- Registration system
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 A new e-mail service "Berlandesk&q ...
- nyoj 911 Registration system(map)
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
随机推荐
- DLog的使用
DLog本质上就是个宏替换.DLog具体代码如下: #ifdef DEBUG #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt) ...
- cutpFTP设置步骤
cutpFTP设置步骤 平常时为了方便两台电脑之间传送数据,我们可以使用cutpftp这个工具实现,而且cutpftp还具有定时传送的功能,非常方便使用.以下是使用该工具的“同步文件夹”功能同步两台电 ...
- 学习一下《JavaEE开发的颠覆者 Spring Boot实战 》
SPRING,绕不过去的.
- 浅析配置更快的Eclipse方法
很多人感觉自己的elipse启动比较慢,其实并不是因为装的插件太多或者是导入的项目有点大,而是因为参数的设置不合理导致的.可以在eclipse.ini里面添加-Xloggc:gc.log看看启动的日志 ...
- hdu 3695:Computer Virus on Planet Pandora(AC自动机,入门题)
Computer Virus on Planet Pandora Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 256000/1280 ...
- sqlplus使用(二)
详见SQL*Plus® User's Guide and Reference Release 11.2 5 Using Scripts in SQL*Plus 1.定义环境变量 _EDITOR ...
- c/s模式 (C#)下Ftp的多文件上传及其上传进度
因为项目要求,制作的一个多文件上传,并显示进度条一段代码(vs2005环境).(只为粗略的实现,代码并不规范) 当多个文件上传的时候,需要依次队列形式一个个上传,当上传某个文件的时候,锁定进程,上传完 ...
- phpcms 完美实现 导航栏当前栏目高亮
我们在用phpcms做网站的时候,经常碰到导航栏高亮功能,或者侧栏高亮,这个会涉及到几个问题: .栏目列表页子栏目高亮判断,如果当前页面为子栏目,他的顶级栏目如果在导航栏也要高亮. .内容页高亮,这个 ...
- Accelerating Matlab
Matlab is a very useful programming environment, but it also has many inefficiencies. You might thin ...
- Zigzag
date: 2015-09-24 21:09:00 Print Zigzag 思路: 1 首先是按行输出,每行输出相同位置的下一间隔为row*2-2,行游标0 初始化时(每一行的首个斜向部分),j=i ...