#P4503. [CTSC2014] 企鹅 QQ

    ID: 3425 远端评测题 2000ms 250MiB 尝试: 3 已通过: 0 难度: 7 上传者: 标签>字符串2014WC/CTSC/集训队哈希,HASH概率论,统计

[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 nn account names, he wants to know how many pairs are similar.

To simplify your work, the nn strings all have length LL, and they contain only uppercase and lowercase letters, digits, the underscore, and @ — a total of 6464 characters. Moreover, no two account names are identical.

Input Format

The first line contains three positive integers N,L,SN, L, S. Here NN is the number of account names, LL is the length of each account name, and SS is the alphabet size, whose value is either 22 or 6464.

If SS equals 22, account names contain only the characters 0 and 1.

If SS equals 6464, account names may contain uppercase and lowercase letters, digits, the underscore, and @ — a total of 6464 characters.

Then NN lines follow, each containing a string of length LL that describes an account name. It is guaranteed that the NN 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 44 similar pairs are: Fax and fax, Fax and max, fax and max, max and mac.

测试点编号 NN LL SS
11 5050 1010 6464
22 500500 100100
33 30003000 22
44 6464
55 3000030000 5050 22
66 6464
77 200200 22
88 6464
99 22
1010 6464

Translated by ChatGPT 5