c题 Registration system
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
4
abacaba
acaba
abacaba
acab
OK
OK
abacaba1
OK
6
first
first
second
second
third
third
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的更多相关文章
- nyoj 991 Registration system (map)
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
- ACM Registration system
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
- 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 ...
- 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 ...
- (用了map) Registration system
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93241#problem/C (654123) http://codeforces.com ...
- 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 ...
随机推荐
- iOS Size Class使用
iOS8和iPhone6发布已经过去蛮久了,广大的果粉终于迎来了大屏iPhone,再也不用纠结为大屏买三星舍苹果了-但是对于iOS开发人员来说,迎来了和Android开发开发一样的问题->各种屏 ...
- [WPF] 为Style 里的button添加鼠标点击响应事件
一个TabControl, 用的是PagedTabControl style, 在style中有个button, button在style里已经写了click事件,但是现在还需要加上一段功能,就是在响 ...
- js检测对象中是否存在某个属性
1.使用in关键字.该方法可以判断对象的自有属性和继承来的属性是否存在. 2.使用对象的hasOwnProperty()方法.该方法只能判断自有属性是否存在,对于继承属性会返回false. 3.用un ...
- centos6 + tomcat+ jdk配置步骤
1. 获取tomcat, jdk安装文件 mkdir /media/smbdirmount -o username=pas,password=111111 //109.110.100.50/pas / ...
- Date对象 识记
1.Date 对象创建 var myDate=new Date() 2.Date 对象属性 constructor pototype 3.Date 对象方法 Date() ...
- HDU 1525 Euclid's Game
题目大意: 题目给出了两个正数a.b 每次操作,大的数减掉小的数的整数倍.一个数变为0 的时候结束. 谁先先把其中一个数减为0的获胜.问谁可以赢.Stan是先手. 题目思路: 无论a,b的值为多少,局 ...
- open()的模块
对文件操作流程: 1.打开文件,得到文件句柄并赋值给一个变量 2.通过句柄对文件进行操作 3.关闭文件 mode can be: * 'r' 只读. * 'w' 写入,如果之前有就覆盖 * 'a' ...
- Win10安装安卓ADB驱动
Win10安装安装ADB驱动 Step1: 首先在黄色感叹号的ADB Interface 点右键菜单,选择“更新驱动程序软件”菜单. 在弹出“更新驱动程序软件”窗口中,选择下面一项“浏览计算机以查找驱 ...
- python zipfile 文件压缩和文件
文件压缩 zipfile_obj = zipfile.ZipFile(zipfile_objpath, 'a', zipfile.ZIP_DEFLATED) for dirpath, dirnames ...
- Windows中 RabbitMQ安装与环境变量配置
RabbitMQ是一个在AMQP基础上完整的,可复用的企业消息系统.他遵循Mozilla Public License开源协议.1:安装RabbitMQ需要先安装Erlang语言开发包.下载地址 ht ...