Guest User

Untitled

a guest
Nov 13th, 2016
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.02 KB | None | 0 0
  1. #include<iostream>
  2. #include<iomanip>
  3. #include<iterator>
  4. #include<list>
  5. #include<math.h>
  6. #include<cstdio>
  7. #include<cstring>
  8. #include<algorithm>
  9. #include<string>
  10. #include<set>
  11. #include<vector>
  12. #include<map>
  13. #include<unordered_map>
  14. #include<queue>
  15. #include<utility>
  16. #include<numeric>
  17. #include<functional>
  18. #define sz(a) int((a).size())
  19. #define pb push_back
  20. #define eb emplace_back
  21. #define mp make_pair
  22. #define mt make_tuple
  23. #define ld(a) while(a--)
  24. #define tci(v,i) for(auto i=v.begin();i<v.end();i++)
  25. #define tcf(v,i) for(auto i : v)
  26. #define all(v) v.begin(),v.end()
  27. #define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
  28. #define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
  29. #define cpresent(c,x) (find(all(c),x) != (c).end())
  30. #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  31. #define osit ostream_iterator
  32. #define MOD         1000000007
  33. #define INF         0x3f3f3f3f
  34. #define LLINF       1000111000111000111LL
  35. #define pi          3.14159265358979323
  36. #define endl '\n'
  37. #ifdef WIN32
  38. #define getchar_unlocked getchar
  39. #endif
  40. #define gc getchar
  41. #define trace1(x)                cerr<<#x<<": "<<x<<endl
  42. #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  43. #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  44. #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  45. #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  46. #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  47. #define N 1000006
  48. using namespace std;
  49. typedef vector<int> vi;
  50. typedef vector<vi> vvi;
  51. typedef long long int ll;
  52. typedef vector<long long int> vll;
  53. typedef vector<vll> vvll;
  54. typedef long double ld;
  55. typedef pair<int,int> ii;
  56. typedef vector<ii> vii;
  57. typedef vector<vii> vvii;
  58. typedef tuple<int,int,int> iii;
  59. typedef set<int> si;
  60. typedef priority_queue<ii,vii,greater<ii> > spq;
  61. template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
  62. template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
  63. template<typename T> T pow(T x,T y){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%MOD;y/=2;x=(x*x)%MOD;}return ans;} //using this instead of inbuilt pow due to precision issues in that
  64. template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}
  65. int main(){
  66.     sync;
  67.     int t; cin>>t; string s;
  68.     vector<string> v;
  69.     map<string,ll> m; map<string,ll> laster;
  70.     rep(j,0,t){
  71.         cin>>s;
  72.         if(!m[s]){
  73.             cout<<s<<endl;  m[s]=1;continue;
  74.         }
  75.         ll curr=laster[s];
  76.         while(m[s+to_string(curr)]) ++curr;
  77.         cout<<s<<curr<<endl;
  78.         laster[s]=curr;
  79.         m[s+to_string(curr)]=1;
  80.     }
  81. }
Add Comment
Please, Sign In to add comment