VisaOA #8
Library Prefix Pairs
估计中等可在线判题
Count ordered index pairs i≠j such that title i is a prefix of title j; different indices with identical titles also count.
输入格式
n (1≤n≤200000), followed by n lines of non-empty lowercase strings, each of length ≤1000, with total length ≤200000; the ranges are site-added to bound Trie memory.
输出格式
Output the number of ordered pairs.
样例 1
输入:
3
ab
abc
ab
输出:
4
样例 2
输入:
1
a
输出:
0
样例 3
输入:
4
car
cart
cat
car
输出:
4