简单题,不多说。
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cctype>
#include <string>
#include <functional>
#include <algorithm>
#include <set>
using namespace std;
int table[] = { 2 , 2 , 2 ,
3 , 3 , 3 ,
4 , 4 , 4 ,
5 , 5 , 5 ,
6 , 6 , 6 ,
7 , 0 , 7 ,
7 , 8 , 8 ,
8 , 9 , 9 ,
9 , 0};
void f(string &str)
{
int cur = 0;
char t[10];
for(int i = 0 ; i < str.size() ; ++i)
{
if(isalnum(str[i]))
{
if(isalpha(str[i]))
t[cur++] = table[str[i] - 'A'] + '0';
else t[cur++] = str[i];
}
if(cur == 3) t[cur++] = '-';
}
t[cur] = 0;
str = t;
}
int main()
{
int n;
cin >> n;
for(int i = 0 ; i < n ; ++i)
{
int m;
cin >> m;
multiset<string> s;
for(int j = 0 ; j < m ; ++j)
{
string str;
cin >> str;
f(str);
s.insert(str);
}
auto iter = s.begin();
int ok = 0;
while(iter != s.end())
{
auto r = s.equal_range(*iter);
int len = distance(r.first , r.second);
if(len > 1)
{
cout << *iter << " " << len << endl;
ok = 1;
}
iter = r.second;
}
if(!ok) cout << "No duplicates." << endl;
if(i < n-1) cout << endl;
}
}