P2037 Telephone Numbers
Description
A telephone number consisting of a long string of digits is usually hard to remember. To make it easier, one approach is to use words to aid memorization. For example, use `Three Tens` to remember `3-10-10-10`.
The standard form of a telephone number is seven digits, split into the first three and the last four digits with a hyphen (for example: `888-1200`). Telephone numbers can be written with letters. The correspondence between letters and digits is as follows:
- `A`, `B`, and `C` correspond to `2`;
- `D`, `E`, and `F` correspond to `3`;
- `G`, `H`, and `I` correspond to `4`;
- `J`, `K`, and `L` correspond to `5`;
- `M`, `N`, and `O` correspond to `6`;
- `P`, `R`, and `S` correspond to `7`;
- `T`, `U`, and `V` correspond to `8`;
- `W`, `X`, and `Y` correspond to `9`.
You will notice that the letters `Q` and `Z` are not present. Hyphens in telephone numbers can be ignored. For example, the standard form of `TUT-GLOP` is `888-4567`, the standard form of `310-GINO` is `310-4466`, and the standard form of `3-10-10-10` is `310-1010`.
If two telephone numbers have the same standard form, then they are considered identical.
Given a phone book, find which telephone numbers are duplicates.
Input Format
The first line contains a positive integer $N$, the number of telephone numbers.
The following $N$ lines each contain one telephone number. Each number consists of digits, uppercase letters (excluding `Q` and `Z`), and hyphens. The length of each telephone number does not exceed $1000$. All telephone numbers are valid.
Output Format
Output all duplicate telephone numbers in lexicographic order, in standard form. After each telephone number, output an integer indicating how many times it appears, separated by a single space. Do not output extra blank lines.
If there are no duplicate telephone numbers, output: `No duplicates.`
Explanation/Hint
Constraints
For $30\%$ of the testdata, $N \le 20$.
For $50\%$ of the testdata, $N \le 10000$.
For $100\%$ of the testdata, $N \le 10^5$.
Translated by ChatGPT 5