fork download
  1. #include<bits/stdc++.h>
  2. #include <cmath>
  3. using namespace std;
  4.  
  5. /* 1 x y
  6.  * 2 x */
  7.  
  8. int main() {
  9. ios_base::sync_with_stdio(false);
  10. cin.tie(NULL);
  11. cout.tie(NULL);;
  12.  
  13. int n;
  14. cin>>n;
  15. map <string, int> mp;
  16. for(int i=0;i<n;i++) {
  17. string s;
  18. cin>>s;
  19. if (mp[s]==0) {
  20. cout<<"OK\n";
  21. mp[s]=1;
  22. }
  23. else {
  24.  
  25. cout<<s<<mp[s]<<"\n";
  26. mp[s]++;
  27. }
  28. }
  29.  
  30.  
  31.  
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 5320KB
stdin
4
abacaba
acaba
abacaba
acab
stdout
OK
OK
abacaba1
OK