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
可以用multiset或者multimap
用map映照容器简单。
 #pragma warning(disable:4786)//忽略超长的一个警告,这个警告对程序没有影响,(map,set)
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(){
int n;
string str;
map<string, int> mp;
cin >> n;
while(n--){
cin >> str;
//键值没有str,则map[str] = 0;
if(mp[str]){
cout << str << mp[str] << endl;
}else{
cout << "OK" << endl;
}
mp[str]++; }
return ;
}
 

nyoj 911 Registration system(map)的更多相关文章

  1. nyoj 991 Registration system (map)

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

  2. nyoj 1112 求次数 (map)

    求次数 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 题意很简单,给一个数n 以及一个字符串str,区间[i,i+n-1] 为一个新的字符串,i 属于[0,strl ...

  3. (用了map) Registration system

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

  4. nyoj Registration system

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

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

  6. Java-集合=第五题 (Map)设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得该Account 对象能够自动分配id。 给定一个List 如下: List list = new ArrayList(); list.add(new A

    第五题 (Map)设计Account 对象如下: private long id; private double balance; private String password; 要求完善设计,使得 ...

  7. Java-map-第一题 (Map)利用Map,完成下面的功能: 从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队。如果该 年没有举办世界杯,则输出:没有举办世界杯。 附:世界杯冠军以及对应的夺冠年份,请参考本章附录。 附录

    第一题 (Map)利用Map,完成下面的功能: 从命令行读入一个字符串,表示一个年份,输出该年的世界杯冠军是哪支球队.如果该 年没有举办世界杯,则输出:没有举办世界杯. 附:世界杯冠军以及对应的夺冠年 ...

  8. ACM Registration system

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

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

随机推荐

  1. bzoj 3396: [Usaco2009 Jan]Total flow 水流【最大流】

    最大流生动形象的板子,注意数组开大点 #include<iostream> #include<cstdio> #include<queue> #include< ...

  2. P4244 [SHOI2008]仙人掌图 II

    传送门 仙人掌直径,以前好像模拟赛的时候做到过一道基环树的直径,打了个很麻烦的然而还错了--今天才发现那就是这个的弱化版啊-- 如果是树的话用普通的dp即可,记\(f[u]\)表示\(u\)往下最长能 ...

  3. ASP.NET MVC5 之 客户端实现文件的下载

    MVC 实现下载功能主要借助于 File 属性: //下载文件接口 public ActionResult GetTrackTempIsc(ICSModels icsModels) { bool fl ...

  4. Hdu 4738 Caocao's Bridges (连通图+桥)

    题目链接: Hdu 4738 Caocao's Bridges 题目描述: 有n个岛屿,m个桥,问是否可以去掉一个花费最小的桥,使得岛屿边的不连通? 解题思路: 去掉一个边使得岛屿不连通,那么去掉的这 ...

  5. ASP.NET GridView 控件绑定 CheckBoxList

    需求:设计这样一个页面,在页面上可以自由选择和展示各省份下城市? 思路:一次性查询出所需的记录(查询数据库的操作不宜写到 C# 代码的循环语句中),并保存到全局变量中,之后根据条件过滤出需要的.可以在 ...

  6. ASP.NET文件操作

    在开发Web程序时,不但有存储在数据库中和XML文件中的数据形式需要处理,而且还有很多诸如文本.Word文档和图片等格式的文件数据需要处理.尤其是在一些信息管理系统中,文档的处理流程贯穿了整个系统的运 ...

  7. 数据采集框架Gobblin简介

    问题导读: Gobblin的架构设计是怎样的? Gobblin拥有哪些组建,如何实现可扩展? Gobblin采集执行流程的过程? 前面我们介绍Gobblin是用来整合各种数据源的通用型ETL框架,在某 ...

  8. MVC之参数验证(一)

    ASP.NET MVC采用Model绑定为目标Action生成了相应的参数列表,但是在真正执行目标Action方法之前,还需要对绑定的参数实施验证以确保其数据的准确性.总地来说,我们可以采用Syste ...

  9. 总结esp8266刷Python的完整的步骤(终极总结)

    2018-04-0319:12:02 从玩microPython 到现在,一路荆棘一路坎坷. 不知道只有我遇到这样的问题还是microPython太不稳定,还是我买的板子太糙.总之遇到了太多问题了. ...

  10. QT开发之旅-Udp聊天室编程

    一.概要设计 登录对话框(继承自QDialog类)进行用户登录查询数据库用户是否存在,注册插入数据到用户表.用户表字段: (chatid int primary key, passwd varchar ...