当前位置:网站首页>C. Registration system(map)
C. Registration system(map)
2022-06-30 15:01:00 【Rabbit doesn't like radish】
C. Registration system
time limit per test5 seconds
memory limit per test64 megabytes
inputstandard input
outputstandard output
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.
Input
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.
Output
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.
Examples
input
4
abacaba
acaba
abacaba
acab
outputCopy
OK
OK
abacaba1
OK
inputCopy
6
first
first
second
second
third
third
output
OK
first1
OK
second1
OK
third1
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<queue>
#include<map>
using namespace std;
const int N=1e5+5;
int main()
{
map<string,int>s;//map The convenience of , I didn't think of it when I was doing the questions
int n;
cin>>n;
while(n--)
{
string str;
cin>>str;
if(s[str])// The number of occurrences of this string
{
cout<<str<<s[str]<<endl;
}
else
cout<<"OK"<<endl;
s[str]++;
}
return 0;
}
// first-class stl ah , I still can't
边栏推荐
- CCF elimination games (Full Score code + problem solving ideas + skill summary) February 2, 2015
- 高清机械原理 · 机械设计经典动图
- How many questions can you answer for the interview of Mechanical Engineer?
- 1035 password (20 points)
- PS dynamic drawing
- For loop and promise to solve the problem of concurrent callback
- Why do high precision CNC machining centers have errors? You should pay attention to these four reasons!
- Text matching - [naacl 2022] GPL
- Clear the route cache in Vue
- 2021-05-12
猜你喜欢

How does hbuilder display in columns?

Sum of CCF digits (full mark code + problem solving idea) 201512-1

Error $(...) size is not a function

PS cutting height 1px, Y-axis tiling background image problem

CCF access control system (Full Score code + problem solving idea) 201412-1

Not satisfied with markdown native code block style? Try this beautify code screenshot tool~~

day02

How to realize selective screen recording for EV screen recording
[email protected][])"/>NoViableAltException([email protected][])

Detailed explanation of settimeout() and setinterval()
随机推荐
Binary rotation array (2)
[extensive reading of papers] sentimental analysis of online reviews with a hierarchical attention network
1105 spiral matrix (25 points)
For loop and promise to solve the problem of concurrent callback
JS to realize simple lottery function
PS tip: the video frame to Layer command cannot be completed because dynamiclink is not available
ES6 notes
Summary of C language interview questions
Add attributes to multimode
CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
Text matching - [naacl 2021] augsbert
I - constructing roads
CCF sequence segmentation (Full Score code + problem solving idea) 201509 -1
1019 general palindromic number (20 points)
The difference between queue and stack
2021-05-12
Text matching - [naacl 2022] GPL
Basic learning notes of C language
Matlab finds prime numbers within 100
Programming exercises: whole point and circle (solution ideas and code implementation)