#P2037. Duplicate Telephone Numbers
Duplicate Telephone Numbers
Duplicate Telephone Numbers
Given a telephone directory with entries that may include digits, letters, and hyphens, convert each telephone number into its standard form and find duplicates. The standard form of a telephone number contains exactly seven digits, with a hyphen inserted after the first three digits (i.e. ddd-dddd). Letters are mapped to digits according to the following correspondence in (\LaTeX) format:
[ \begin{array}{ccc} A,,B,,C &\rightarrow& 2 \ D,,E,,F &\rightarrow& 3 \ G,,H,,I &\rightarrow& 4 \ J,,K,,L &\rightarrow& 5 \ M,,N,,O &\rightarrow& 6 \ P,,R,,S &\rightarrow& 7 \ T,,U,,V &\rightarrow& 8 \ W,,X,,Y &\rightarrow& 9 \end{array} ]
Note that the letters Q and Z are not used. Hyphens in the input can be ignored. For example, the input "TUT-GLOP" is converted to "8884567", which then is formatted as "888-4567". Two telephone numbers are considered the same if their standard forms are identical.
Your task is: given a directory of telephone numbers, identify those numbers that occur more than once and output each duplicate number in ascending order along with its frequency. If there are no duplicates, output the string No duplicates.
inputFormat
The input begins with a positive integer N (N ≤ 100,000) indicating the number of telephone numbers in the directory. The following N lines each contain a telephone number. Each telephone number consists of a combination of digits, uppercase letters and hyphens.
outputFormat
For each telephone number that appears more than once, output a line with its standard form and the frequency count, separated by a space. The standard form is formatted as ddd-dddd
. The duplicate numbers should be output in ascending order. If there are no duplicates, output No duplicates.
sample
12
4873279
ITS-EASY
888-4567
3-10-10-10
888-GLOP
TUT-GLOP
967-11-11
310-GINO
F101010
888-1200
-4-8-7-3-2-7-9-
487-3279
310-1010 2
487-3279 4
888-4567 3
</p>