#P4503. [CTSC2014] 企鹅 QQ
[CTSC2014] 企鹅 QQ
Description
Xiao Q (pinyin) is an administrator of the PenguinQQ website. He is studying an interesting question: which accounts were registered by the same person. After long analysis, Xiao Q found that accounts registered by the same person usually have very similar names, such as Penguin1, Penguin2, Penguin3... So he decides to first count such similar cases.
Xiao Q defines two account names to be similar if and only if the two strings have the same length and differ in exactly one position. For example, “Penguin1” and “Penguin2” are similar, while “Penguin1” and “2Penguin” are not. Given account names, he wants to know how many pairs are similar.
To simplify your work, the strings all have length , and they contain only uppercase and lowercase letters, digits, the underscore, and @ — a total of characters. Moreover, no two account names are identical.
Input Format
The first line contains three positive integers . Here is the number of account names, is the length of each account name, and is the alphabet size, whose value is either or .
If equals , account names contain only the characters 0 and 1.
If equals , account names may contain uppercase and lowercase letters, digits, the underscore, and @ — a total of characters.
Then lines follow, each containing a string of length that describes an account name. It is guaranteed that the strings are pairwise distinct.
Output Format
Output a single integer on one line, the number of pairs of similar account names.
4 3 64
Fax
fax
max
mac
4
Hint
The similar pairs are: Fax and fax, Fax and max, fax and max, max and mac.
| 测试点编号 | |||
|---|---|---|---|
Translated by ChatGPT 5
京公网安备 11011102002149号