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 ...
随机推荐
- 【搜索】P1032 字串变换
题目描述 已知有两个字串A,B及一组字串变换的规则(至多6个规则): A1 ->B1 A2 -> B2 规则的含义为:在 A中的子串 A1 可以变换为B1,A2 可以变换为 ...
- 从postgres数据库逆向生成hibernate实体类
最近整理 一个项目,原先的项目是用的oracle,然而新的项目要用postgresql.将oracle数据库导出之后,通过powerdesigner整理,导出postgresql的脚本,然后在post ...
- python3 yum not found
vi /urs/bin/yum 将#!/usr/bin/python的python改为python2.x(你系统的python2的版本)
- 【MyBatis】MyBatis Tomcat JNDI原理及源码分析
一. Tomcat JNDI JNDI(java nameing and drectory interface),是一组在Java应用中访问命名和服务的API,所谓命名服务,即将对象和名称联系起来,使 ...
- python计算圆面积
#coding=gbk #coding=utf-8 #-*- coding: UTF-8 -*- #调用math包处理相关的运算 import math #圆半径 r = 2 #计算圆面积π*r*r与 ...
- 转:使用 /proc 文件系统来访问 Linux 内核的内容
使用 /proc 文件系统来访问 Linux 内核的内容 https://www.ibm.com/developerworks/cn/linux/l-proc.html /proc 文件系统并不是 G ...
- linux网络原理
1.ipconfig命令使用 显示所有正在启动的网卡的详细信息或设定系统中网卡的IP地址. 某一块网卡信息 打开或者关闭某一块网卡 2.ifup和ifdown ifup和ifdown分别是加载网卡信息 ...
- C语言学习11
直接插入排序 //直接插入排序 #include <stdio.h> void main() { ], i; int insort(int a[], int n); printf(&quo ...
- NBUT 1651 - Red packet (求运气王的钱数)(二分法)
Description New Year is coming! Our big boss Wine93 will distribute some “Red Package”, just like Al ...
- uva12558 Egyptian Fractions (HARD version)(迭代深搜)
Egyptian Fractions (HARD version) 题解:迭代深搜模板题,因为最小个数,以此为乐观估价函数来迭代深搜,就可以了. #include<cstdio> #inc ...