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 ...
随机推荐
- Android设置窗体Activity背景透明
背景透明 style.xml <item name="android:windowBackground">@color/transparent</item> ...
- fedora22 mysql安装
fedora19以后好像取消了对mysql的支持,看其他人好像说是用的mariadb的.centos里用yum安装的方式,放到fedora中不能用,所以找了很多资料,尝试了一种可行的办法. 在Fedo ...
- NYOJ-102 次方求模
次方求模 时间限制:1000 ms | 内存限制:65535 KB 难度:3 描述 求a的b次方对c取余的值 输入 第一行输入一个整数n表示测试数据的组数(n<100)每组测试只有一 ...
- docker命令和后台参数
Docker官方为了让用户快速了解Docker,提供了一个 交互式教程 ,旨在帮助用户掌握Docker命令行的使用方法. Docker 命令行 下面对Docker的命令清单进行简单的介绍,详细内容在后 ...
- H264中的MapUnits
1 MapUnits 在FMO(Flexible Macroblock ordering)时,从宏块到条带组的映射是以MapUnits为基本单位,MapUnits可能为宏块,也可能是上下两个宏块(见下 ...
- selenium+python在Windows的环境搭建
1 python下载安装 python早已安装,不再多说.因为开发使用的python2.7,所以同样使用2.7 2 打开Powershell, 输入python -m pip install sele ...
- NIO和IO(转)
java NIO由以下几个核心部分组成: Channels(通道) Buffers(缓冲区) Selectors(选择器) 其他 Channel和Buffer: 所有的IO再NIO中都从一个Chann ...
- ionic中$ionicPopover和$ionicModal
Popover可点多个按钮弹出同一个浮动框但内容不一样.那想要在同一页面弹出不同的浮动框怎么办呢? 这事就用到了$ionicModal,他和$ionicPopover一样的用法. 请看图: html: ...
- java 生成证书用于https
在jdk的bin目录下运行: keytool -genkeypair -alias "tomcat" -keyalg "RSA" -keystore " ...
- CachedRowSet的用法
String sql="select item_code from xt_dictionary_item where type_id='32' and parent_itemid='0' o ...