fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. using namespace std;
  6.  
  7. class username{
  8. public:
  9. username(string a = "0");
  10. friend istream & operator >> (istream & in, username & a);
  11. friend ostream & operator << (ostream & out, username & a);
  12. // friend int isThere (int n, int a, username * base);
  13. friend bool operator < (const username a, const username b);
  14.  
  15. string nick;
  16. private:
  17. };
  18.  
  19. username::username(string a){
  20. nick = a;
  21. }
  22.  
  23. istream & operator>>(istream &in, username &a){
  24. string name;
  25. in >> name;
  26. a = username(name);
  27. return in;
  28. }
  29. ostream & operator<<(ostream &out, username &a){
  30. out << a.nick;
  31. return out;
  32. }
  33.  
  34.  
  35. inline bool operator < (const username a, const username b){
  36. if (a.nick<b.nick)
  37. return 1;
  38. else return 0;
  39. }
  40.  
  41. int main()
  42. {
  43. std::ios::sync_with_stdio(false);
  44. int n = 0;
  45. cin >> n;
  46. string s;
  47.  
  48. map < username,int > m;
  49. while(n--){cin>>s;
  50. if(m[s]++)
  51. cout<<s<<m[s]-1;
  52. else
  53. cout<<"OK";
  54. cout<<endl;}
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0s 15248KB
stdin
Standard input is empty
stdout
Standard output is empty