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 ...
随机推荐
- linux for 使用
第一种:命令使用方法 例子1: cat test.txt 1 2 3 for i in $(cat test.txt) do echo $i done 例子2: for i in 1 2 3 4 do ...
- R安装
linux: 在编译R之前,需要通过yum安装以下几个程序: #yum install gcc-gfortran #否则报”configure: error: No F77 ...
- Gentoo网络管理方法总结
OpenRC/netifrc Netifrc is a collection of modules created to configure and manage network interfaces ...
- .netER的未来路,关于基础是否重要和应该自己手写代码吗?
http://www.cnblogs.com/onepiece_wang/p/5558341.html#!comments 引用"基础知识的学习,一开始可能是背书,但是在后续若干年的工作过程 ...
- drupal7 sql接口笔记
1.查询: execute() ->fetch():从结果集中取出一行作为一个对象 execute() ->fetchField():获取单个值 execute() ->fetchA ...
- curl 使用
1.cURL介绍 cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP.FTP.TELNET等.最爽的是,PHP也支持 cURL 库.本文将介绍 cURL 的一些高级特性 ...
- log4j.properties 的使用详解
一.log4j.properties 的使用详解 1.输出级别的种类 ERROR.WARN.INFO.DEBUGERROR 为严重错误 主要是程序的错误WARN 为一般警告,比如session丢失IN ...
- Docker 安装及问题处理
1 确定Linux版本 uname -r 2 升级系统(添加 APT 镜像源,添加使用 HTTPS 传输的软件包以及 CA 证书.) sudo apt-get update sudo apt-get ...
- log4j.properties全配置 (转)
###############################log4j.properties############################### ##### Global Log Leve ...
- winform 制作圆形图片框
public partial class CirclePictureBox : PictureBox { public CirclePictureBox() { Circle = true; Init ...