Source Code
#include <iostream>
#include<map>
#include<string.h>
using namespace std ;
 
int main() {
 int n;
 map <string , int > m;
 cin>>n; 
 for(int i = 0 ; i<n ;i++)
 {
     string s ; 
     cin>>s ; 
     m[s]++;
     if(m[s]== 1)cout<<"OK"<<endl;
     else 
     {
       
      char a [s.size()+1] ;
      char freq = (m[s]-1)+'0';
      for(int i = 0 ; i<s.size() ; i++)
        a[i]=s[i];
      a[s.size()] = freq;
      a[s.size()+1] ='\0';
      while(m[a]>0)
        {
          a[s.size()]++;
        }
       cout<<a<<endl;
       m[a]++;
     } 
   
 }
 
}
Copy
Registration System Tala_Ibraheem
GNU G++17
1 ms
236 KB
Wrong Answer