Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define num 1000000007
- #define formn(i,m,n) for(i=m;i<n;i++)
- #define forn(i,n) for(i=0;i<n;i++)
- #define fmno(i,m,n,o) for(i=m;i<n;i+=o)
- #define ll long long
- using namespace std;
- int main() {
- long long i=0,j,k,n,t;
- cin>>t;
- while(t--)
- {
- cin>>n;
- k=0;
- vector<string> a(n);
- set<string> b;
- multiset<string> c;
- ll ini;
- forn(i,n)
- {
- cin>>a[i];
- c.insert(a[i]);
- }
- forn(ini,n)
- {
- i=b.size();
- b.insert(a[ini]);
- c.erase(c.find(a[ini]));
- char ch='0',p;
- for(int j=3;j>=0;j--)
- while(b.size()<=i)
- {
- p=a[ini][j];
- a[ini][j]= ch;
- if(c.find(a[ini])==c.end() && b.find(a[ini])==b.end())
- {
- k++;
- b.insert(a[ini]);
- break;
- }
- a[ini][j]=p;
- ch = ch + 1;
- //cout<<ch;
- }
- }
- cout<<k<<'\n';
- forn(i,n)
- {
- cout<<a[i]<<" ";
- }
- cout<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement