Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<iomanip>
- #include<iterator>
- #include<list>
- #include<math.h>
- #include<cstdio>
- #include<cstring>
- #include<algorithm>
- #include<string>
- #include<set>
- #include<vector>
- #include<map>
- #include<unordered_map>
- #include<queue>
- #include<utility>
- #include<numeric>
- #include<functional>
- #define sz(a) int((a).size())
- #define pb push_back
- #define eb emplace_back
- #define mp make_pair
- #define mt make_tuple
- #define ld(a) while(a--)
- #define tci(v,i) for(auto i=v.begin();i<v.end();i++)
- #define tcf(v,i) for(auto i : v)
- #define all(v) v.begin(),v.end()
- #define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
- #define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
- #define cpresent(c,x) (find(all(c),x) != (c).end())
- #define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define osit ostream_iterator
- #define MOD 1000000007
- #define INF 0x3f3f3f3f
- #define LLINF 1000111000111000111LL
- #define pi 3.14159265358979323
- #define endl '\n'
- #ifdef WIN32
- #define getchar_unlocked getchar
- #endif
- #define gc getchar
- #define trace1(x) cerr<<#x<<": "<<x<<endl
- #define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
- #define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
- #define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
- #define trace5(a, b, c, d, e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
- #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
- #define N 1000006
- using namespace std;
- typedef vector<int> vi;
- typedef vector<vi> vvi;
- typedef long long int ll;
- typedef vector<long long int> vll;
- typedef vector<vll> vvll;
- typedef long double ld;
- typedef pair<int,int> ii;
- typedef vector<ii> vii;
- typedef vector<vii> vvii;
- typedef tuple<int,int,int> iii;
- typedef set<int> si;
- typedef priority_queue<ii,vii,greater<ii> > spq;
- template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
- 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; }
- 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
- 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;}
- int main(){
- sync;
- int t; cin>>t; string s;
- vector<string> v;
- map<string,ll> m; map<string,ll> laster;
- rep(j,0,t){
- cin>>s;
- if(!m[s]){
- cout<<s<<endl; m[s]=1;continue;
- }
- ll curr=laster[s];
- while(m[s+to_string(curr)]) ++curr;
- cout<<s<<curr<<endl;
- laster[s]=curr;
- m[s+to_string(curr)]=1;
- }
- }
Add Comment
Please, Sign In to add comment