logo AlgoBeat OnlineJudge
登录 注册

#203390. [COCI 2017/2018 #1] Lozinke

内存限制:63 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

样例

样例输入 1

3
aaa
aa
abb

样例输出 1

1

样例输入 2

3
x
x
xy

样例输出 2

4

样例输入 3

5
mir
mirta
ta
ir
t

样例输出 3

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.