Registration system

时间限制:1000 ms  |  内存限制:65535 KB
难度:2
描写叙述

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的更多相关文章

  1. ACM Registration system

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

  2. 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 ...

  3. c题 Registration system

    Description A new e-mail service "Berlandesk" is going to be opened in Berland in the near ...

  4. CodeForces-4C Registration system

    // Registration system.cpp : 此文件包含 "main" 函数.程序执行将在此处开始并结束. // #include <iostream> # ...

  5. nyoj Registration system

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

  6. (用了map) Registration system

    http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93241#problem/C (654123) http://codeforces.com ...

  7. codeforces Registration system

     Registration system A new e-mail service "Berlandesk" is going to be opened in Berland in ...

  8. 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 ...

  9. nyoj 911 Registration system(map)

    Registration system 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 A new e-mail service "Berlandesk&q ...

随机推荐

  1. js中重载问题

    在js中是没有重载的  但是  Arguments对象(可以实现模拟重载的效果) 利用arguments对象的length属性,可以获取函数接收的参数的个数 例如: function add(){ i ...

  2. 爬虫学习之第一次获取网页内容及BeautifulSoup处理

    from urllib.request import urlopen from urllib.request import HTTPError from bs4 import BeautifulSou ...

  3. JavaEE-08 JSTL和EL

    学习要点 EL表达式 JSTL标签 EL表达式 为什么需要EL表达式 JavaBean在JSP中的局限 在JSP页面中嵌入大量的Java代码 获取JavaBean属性必须要实例化 强制类型转化 例如, ...

  4. git-忽略文件改动不进行提交

    命令:git update-index --assume-unchanged 文件名 作用:忽略文件的改动,但是不加入.gitignore 文件中,这样可以达到仅在本地目录中忽略,不影响其他团队成员的 ...

  5. STL源码分析-iterator(迭代器)

    1. GOF 迭代器设计模式 前面一篇文章有写到stl_list的实现,也实现了一下相应的iterator,但是后面觉得,实现具体容器之前有必要介绍一下iterator(迭代器) .那么迭代器是什么呢 ...

  6. ArrayList 和 LinkedList 区别。

    1. ArrayList和LinkedList都是实现了List接口的容器类,用于存储一系列的对象引用.他们都可以对元素的增删改查进行操作. 2. ArrayList是实现了基于动态数组的数据结构,L ...

  7. 2019天梯赛练习题(L1专项练习)

    7-1 水仙花数 (20 分) 水仙花数是指一个N位正整数(N≥3),它的每个位上的数字的N次幂之和等于它本身.例如:1. 本题要求编写程序,计算所有N位水仙花数. 输入样例: 3 输出样例: 153 ...

  8. day15-python之变量和递归

    1.局部变量与全局变量 #!/usr/bin/env python # -*- coding:utf-8 -*- # name='lhf' # def change_name(): # global ...

  9. 02 requests模块

    requests模块 requests是用python语言基于urllib编写的,采用的是Apache2 Licensed开源协议的HTTP库,requests会比urllib更加方便,可以节约我们大 ...

  10. java中String数组和List的互相转化

    1.List转String数组 方法一: //先准备一个List List<String> testList=new ArrayList<>(); testList.add(& ...