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
my answer: 
#include<iostream>
#include<map>
using namespace std;
int main()
{int n;cin>>n;string str;map<string,int> ma;while(n--){cin>>str;if( ma[str]!= 0) {cout<<str<<ma[str]<<endl;ma[str]++;}else{cout<<"OK"<<endl;ma[str]=0;ma[str]++;}}return 0;
}

Registration system相关推荐

  1. Registration system(翻译 day 3)

    来源:codeforces:Problem - C - Codeforces Registration system(注册系统) A new e-mail service "Berlande ...

  2. NYOJ991 Registration system 【set的用法】

    原题链接 #include <set> #include <iostream> #include <cstdio> #include <string> ...

  3. Codeforces Beta Round #4 (Div. 2)【完结】

    2022.3.3 题单地址:https://codeforces.com/contest/4 目录 A. Watermelon[思维] B. Before an Exam[贪心] C. Registr ...

  4. FFmpeg过滤器框架分析

    FFmpeg过滤器框架分析 目录 主要结构体和API介绍 AVFilterGraph-对filters系统的整体管理 AVFilter-定义filter本身的能⼒ AVFilterContext-fi ...

  5. android签到功能模块,基于android的课堂签到系统.doc

    基于android的课堂签到系统 本科毕业论文(设计) 题 目 基于Android的课堂签到系统 学生姓名 XXX 指导教师 XX 学 院 信息科学与工程学院 专业班级 计算机科学与技术0908班 完 ...

  6. 字符串处理 —— 模拟与暴力

    [概述] 在某些题目中,需要对字符串进行处理,不需要很复杂的算法,只需要按照题意进行模拟或暴力枚举即可得出答案. [例题] 1.简单模拟 Minimum Ternary String(CF-1009B ...

  7. 【ECCV2020】接收论文列表part1

    ECCV2020将于2020年8月23-28日在线上举行,今年共接受了1361篇论文,本文是接收论列表的第一部分,第二部见链接 Paper ID Paper Title Category 267 Qu ...

  8. node.js编写网页_为Node.js编写可扩展架构

    node.js编写网页 by Zafar Saleem 通过Zafar Saleem 为Node.js编写可扩展架构 (Writing Scalable Architecture For Nodejs ...

  9. ECCV 2020 论文大盘点-图像与视频分割篇

    分割是ECCV 2020 中的热门关键词,前文已经总结了: ECCV 2020 论文大盘点-语义分割篇 ECCV 2020 论文大盘点-实例分割篇 但"分割"本身的内涵很丰富,还包 ...

最新文章

  1. 基于OHCI的USB主机 —— 结束语
  2. Android APK反编译具体解释(附图)
  3. Centos(6、7) —— yum源的配置
  4. java jvm调优面试题_【Java面试题第一期】有没有jvm调优经验?调优方案有哪些?...
  5. linux 查询内存和核心数,Linux下查看操作系统信息、内存情况及cpu信息:cpu个数、核心数、线程数...
  6. java.util.Collections类使用(很多秘密,网上资料亲测)
  7. SDK学院--易接网游SDK中间件接入使用说明-Unity3D游戏接口
  8. 简单74LS138介绍(抄自原理图)
  9. 在线rar压缩包解密软件,忘记rar压缩包密码如何找回?
  10. 服务器开机系统进不去怎么办,开机就进BIOS进不去系统怎么处理
  11. android水果界面设计,一套小清新的水果元素的APP界面设计欣赏
  12. 京东11.11:商品搜索系统架构设计解密
  13. 【Learncpp中文翻译版】【1.9、1.10、1.11】
  14. 免费的ipad编辑php软件下载,免费也很香!8 款免费 APP 打造你的学术型 iPad
  15. vue 简单实现组件自动注册
  16. 关于win 10电脑连接手机热点自动断开的问题
  17. The system cannot find the path specified
  18. linux查看单词个数,Linux怎么统计文本的的行数/单词数和字符数?
  19. 我的java学习之路之Spring MVC
  20. Win10配置pytorch深度学习环境

热门文章

  1. 【OpenGL开发】VS2017+nuget配置OpenGL开发环境
  2. Ceph原理、部署、存储集群、块存储及对象存储centos7.5
  3. python菜鸟教程python机器学习工具库
  4. 【两个队列模拟栈】——栈与队列
  5. FE310三个版本的差异
  6. java/php/net/python互联网 智慧云诊所管理系统设计
  7. 酷狗服务器显示失败怎么回事,酷狗音乐如何分享音乐失败怎么办 ?酷狗音乐分享音乐失败如何解决?...
  8. 字节算法题--N阶台阶,每次走一步或两步,计算共有多少种走法,并将每种走法打印出来。
  9. 使用Altium Designer 绘制PCB的详细过程
  10. 利用串口网络助手上传数据、图片到OneNet平台以及获取数据(HTTP)