#P4421. [COCI2017-2018#1] Lozinke
[COCI2017-2018#1] Lozinke
题目描述
Recently, there has been a breach of user information from the mega-popular social network Secret Network. Among the confidential information are the passwords of all users.
Mihael, a young student who has been exploring computer security lately, found the whole thing really interesting. While experimenting with the social network, he found another security breach! When you input any string of characters that contains a substring equal to the actual password, the login will be successful. For example, if the user whose password is abc inputs one of the strings abc, abcd or imaabcnema, the system will successfully log him in, whereas the login will fail for axbc.
Mihael wants to know how many ordered pairs of different users exist such that the first user, using their own password, can login as the second user.
输入格式
The first line of input contains the positive integer N (1 ≤ N ≤ 20 000), the number of users.
Each of the following N lines contains the user passwords. The passwords consist of at least one and at most 10 lowercase letters of the English alphabet.
输出格式
The first and only line of output must contains the number of ordered pairs from the task.
题目大意
【题目描述】
最近,某社交网络平台出现了用户信息的泄露。
Mihal 是一个喜欢探索计算机安全的学生,他发现整个事情非常有趣。在经过一段时间的研究,他发现了一个安全漏洞。当你输入任何字符串时,如果用户的密码在这个字符串中出现, 那么你就可以通过这个字符串成功登录。 例如,如果密码为 abc 的用户输入了一个字符串为 abc 或 abcdde 或 imaabcnema,他将会成功登录,而 axbc 则会登录失败。
现在 Mihal 想知道会出现多少次用户可以用自己的密码成功登录其他用户的情况。
【输入】
输入第一行为正整数 N,表示用户数量。(N<=20000)
接下来 N 行包含 N 个用户的密码,每个密码小写字母组成,长度不超过 10。
【输出】
输出共一行,输出出现用户可以用自己的密码成功登录其他用户的总次数。
【样例3解释】
第一个用户可以成功登录第二个用户,第二个用户可以成功登录第一个用户,第三个用户可以登录第一个用户和第二个用户,总共出现 4 次本用户成功登录其他用户的情况。
3
aaa
aa
abb
1
3
x
x
xy
4
5
mir
mirta
ta
ir
t
6
提示
Clarification of the second test case:
The first user can login as the second user, the second user can login as the first, and the third user can login as both the first and the second user.