-
Notifications
You must be signed in to change notification settings - Fork 0
/
00755.cpp
44 lines (40 loc) · 958 Bytes
/
00755.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <bits/stdc++.h>
using namespace std;
int main()
{
// freopen("in.txt","r",stdin);
map<int,int> ma;
int TC,n,x,arr[26];
char ins[20],tar[][4] = {"QZ","","ABC","DEF","GHI","JKL","MNO","PRS","TUV","WXY"};
bool first = true,has;
for(int i = 0;i < 10;i++) for(int j = 0;tar[i][j];j++) arr[tar[i][j] - 'A'] = i;
scanf("%d",&TC);
while(TC--)
{
ma.clear();
if(!first) puts("");
first = false;
scanf("%d",&n);
while(n--)
{
scanf("%s",ins);
x = 0;
for(int i = 0;ins[i];i++)
{
if(isdigit(ins[i])) x = x*10 + ins[i] - '0';
if(isalpha(ins[i])) x = x*10 + arr[ins[i] - 'A'];
}
if(ma.find(x) == ma.end()) ma.insert(make_pair(x,1));
else ma[x]++;
}
has = false;
for(map<int,int>::iterator it = ma.begin();it != ma.end();it++)
if(it->second > 1)
{
printf("%03d-%04d %d\n",it->first / 10000,it->first % 10000,it->second);
has = true;
}
if(!has) printf("No duplicates.\n");
}
return 0;
}