Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- map<string,int>mp;
- set<string>st;
- char s[20];
- string convert;
- char letter[100];
- void built_in()
- {
- letter['A'] = '2';letter['B'] = '2';letter['C'] = '2';
- letter['D'] = '3';letter['E'] = '3';letter['F'] = '3';
- letter['G'] = '4';letter['H'] = '4';letter['I'] = '4';
- letter['J'] = '5';letter['K'] = '5';letter['L'] = '5';
- letter['M'] = '6';letter['N'] = '6';letter['O'] = '6';
- letter['P'] = '7';letter['R'] = '7';letter['S'] = '7';
- letter['T'] = '8';letter['U'] = '8';letter['V'] = '8';
- letter['W'] = '9';letter['X'] = '9';letter['Y'] = '9';
- }
- struct info
- {
- string dial;
- int cnt;
- }arr[100005];
- int main()
- {
- built_in();
- int n,tc,test,i,j,k,len;
- scanf("%d",&test);
- for(tc=1;tc<=test;tc++)
- {
- scanf("%d",&n);
- k = 0;
- for(i=1;i<=n;i++)
- {
- scanf("%s",s);
- len = strlen(s);
- convert="";
- for(j=0;j<len;j++)
- {
- if(s[j]>='0' && s[j]<='9')
- {
- convert+=s[j];
- }
- else if(s[j]!='Q' && s[j]!='Z' && s[j]>='A' && s[j]<='Y')
- {
- convert+=letter[s[j]];
- }
- }
- mp[convert]++;
- st.insert(convert);
- }
- for(auto it: st)
- {
- arr[++k].dial = it;
- arr[k].cnt = mp[it];
- }
- bool dhukse = false;
- for(i=1;i<=k;i++)
- {
- if(arr[i].cnt>1)
- {
- dhukse = true;
- for(j=0;j<=2;j++)
- {
- printf("%c",arr[i].dial[j]);
- }
- printf("-");
- for(j=3;j<=6;j++)
- {
- printf("%c",arr[i].dial[j]);
- }
- printf(" %d\n",arr[i].cnt);
- }
- }
- if(!dhukse)
- {
- puts("No duplicates.");
- }
- mp.clear();
- st.clear();
- if(tc<test)
- puts("");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment