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 - 来源
- 爱生活
-
上传者
userid=TCM_%E5%BC%A0%E9%B9%8F" style="text-decoration:none; color:rgb(55,119,188)">TCM_张鹏
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
using namespace std;
int main()
{
int T,i,j,count;
string a[200];
cin>>T;
for(i=0;i<T;i++)
{
count=0;
cin>>a[i];
for(j=0;j<i;j++)
{
if(strcmp(a[i].c_str(),a[j].c_str())==0)
{
count++;
}
}
if(count==0)
printf("OK\n");
else
cout<<a[i]<<count<<endl;
}
return 0;
}
Registration system的更多相关文章
- 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 ...
- 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 ...
- (用了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 ...
- nyoj 911 Registration system(map)
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
随机推荐
- com组件简单应用
1.打开VS2010,新建ATL COM 项目,步骤:“文件” -->“新建” -->“项目”,选择“Visual C++” -->“ATL 项目” ,填写“名称” FirstCOM ...
- 把txt格式数据制作成xml数据
txt格式数据: 代码: s1=""" <object> <name>{0}</name> <pose>Unspecifi ...
- Angular JavaScript内存溢出问题 (FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory)
方法一和方法二参考:https://www.cnblogs.com/liugang-vip/p/6857595.html 方法一:my-project/node_modules/.bin 下增大内存( ...
- 文本三剑客之sed
sed是一个流编辑器(sed是stream editor的缩写),它可以对从标准输入流中得到的数据进行处理,然后把处理以后得到的结果输出到标准输出,而标准输出通常会关联到终端屏幕,因此处理后的结果也会 ...
- 美团技术分享:大众点评App的短视频耗电量优化实战
美团技术专栏: 关注MAYOU18 前言 美团测试团队负责App的质量保证工作,日常除了App的功能测试以外,还会重点关注App的性能测试.现在大家对手机越来越依赖,而上面各App的耗电量,直接影响了 ...
- 五分钟掌握 for...in 和 for...of 区别
GitHub 地址,欢迎star,查看更多整理的前端知识 for...in for...in 语句以任意顺序遍历一个对象的可枚举属性. for...in 遍历对象本身的所有可枚举属性,以及对象从其构造 ...
- C语言之static用法
1,static修饰全局变量 限定变量的作用域.被static修饰的全局变量存储域不变,依然存储在静态存储区,即bss段或data段.但作用域发生改变,被static修饰全局变量只能被本文件的函数访问 ...
- @RestController 与 @Controller 注解区别
文章来源:https://www.cnblogs.com/hello-tl/p/9202658.html @RestController注解相当于@ResponseBody + @Controller ...
- SSM调用数据库存储过程
ServiceImpl中: Map<String,Object> map=new HashMap<String,Object>(); map.put("bid&quo ...
- javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean (蛋疼死我了)
1为抛出异常原因,2为异常解决方法. 原因: 进入spring:bind标签源码你可以看到 Object target = requestContext.getModelObject(beanNa ...