codeforces 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 32 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
6
first
first
second
second
third
third
OK
first1
OK
second1
OK
third1 用的map做的。
#include <bits/stdc++.h>
using namespace std;
map<string, int> c;
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0);
c.clear();
int t,i;
char s[];
scanf("%d ",&t);
for(i=;i<=t;i++)
{
cin>>s;
c[s]++;
auto p=c.find(s);
if(p->second>) cout<<p->first<<p->second-<<endl;
else cout<<"OK"<<endl;
}
return ;
}
codeforces Registration system的更多相关文章
- 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 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 ...
 - (用了map) Registration system
		
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=93241#problem/C (654123) http://codeforces.com ...
 - ACM Registration system
		
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
 - 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 ...
 - Registration system
		
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 A new e-mail service "Berlandesk&q ...
 - nyoj 911 Registration system(map)
		
Registration system 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 A new e-mail service "Berlandesk&q ...
 
随机推荐
- DFS+BFS(POJ3083)
			
题目链接:http://poj.org/problem?id=3083 解题报告:这个题目,搜最短路,没有什么问题.优先走左边,走右边,有很多说法,思路大概都相同,都是记录当前朝向,根据数学公式(i+ ...
 - service 入门
			
https://www.cnblogs.com/keguangqiang/p/3663086.html#undefined
 - sql查询字段值长度判断是否18位
			
SELECT * FROM 表名 WHERE LENGTH(字段)= OR 字段为null IS NULL OR 字段为空='' SELECT * FROM 表名 WHERE LENGTH(字段)&g ...
 - matlab 读取文件(mat)存储为json文件
			
fid= fopen('reqJosn.json', 'w+'); load('request-set-10.mat'); requests = requests.request; requestNu ...
 - Spring的jdbcTemplate 与原始jdbc 整合c3p0的DBUtils 及Hibernate 对比 Spring配置文件生成约束的菜单方法
			
以User为操作对象 package com.swift.jdbc; public class User { private Long user_id; private String user_cod ...
 - mybatis异常:Could not find result map ......... 问题分析及解决
			
org.apache.ibatis.builder.IncompleteElementException: Could not find result map....... 网上的大部分的改正方法是: ...
 - css设置内容超出后显示省略号
			
1.使用overflow: hidden把超出的内容进行隐藏: 2.然后使用white-space: nowrap设置内容不换行: 3.最后使用text-overflow: ellipsis设置超出内 ...
 - 为什么 redis 单线程却能支撑高并发
			
redis 和 memcached 有什么区别?redis 的线程模型是什么?为什么 redis 单线程却能支撑高并发? 这个是问 redis 的时候,最基本的问题吧,redis 最基本的一个内部原理 ...
 - PHP 微信公众号之客服完整讲解
			
//获取access_token private static function get_access_token($app_id) { $getAuthorizerInfo = wx_auth::g ...
 - bash:/usr/bin/mogod/:connot execute binary:exec fotmat error
			
前两天博主在安装mogodb的时候出现以下错误,很是郁闷,明明按照教程里面做的,怎么到最后 执行命令的时候出错了呢,以下为错误execute binary:exec fotmat error" ...