NYOJ --- question 991 regijian system

Source: Internet
Author: User

NYOJ --- question 991 regijian system

Description

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 shoshould 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

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 1000 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.
Sample Input
4abacabaacabaabacabaacab
Sample output
OKOKabacaba1OK
Source
Love life
Uploaded
TCM _ Zhang Peng
 #include
     
      #include
      
       #include
       #include
        
         #include
         
          using namespace std;int main(){    map
          
           mp; string s; int test; while(cin>>test) { for(int i=0;i
           
            >s; if(mp[s]==0) { printf("OK\n"); mp[s]++; } else { cout<
            
           
          
         
        
      
     

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.