printРабочее место участника

printЗадачи

1863. Dictionary Size

Ограничения: время – 2s/4s, память – 256MiB Ввод: input.txt или стандартный ввод Вывод: output.txt или стандартный вывод copy
Послать решение Blockly Посылки Темы Где Обсудить (0)

The government of Disleksik Piple's Ripublyc had decided to improve literacy level of its citizens. To this end, the government issued a decree with a full list of dictionary words.
The rules for construction of new words were also greatly simplified: an approved word must either be a dictionary word or consist of two parts, where the first part must be a dictionary word or its non-empty prefix, and the second part –- a dictionary word or its non-empty suffix.
The Institute of Language Simplification has assigned you the task to count the number of different approved words that can be constructed from the given dictionary.
The first line of the input file contains the number of dictionary words `n` (`1\ ≤\ n\ ≤\ 10000`). The following `n` lines contain dictionary words, one word per line. Dictionary words are composed of lowercase Latin letters and are at least 1 and at most 40 letters in length.
The Institute of Language Simplification did not necessary do a good job of cleaning the input data, so their list may contain duplicates.
The output file must contain a single integer –- the number of different approved words.

Sample Input

3
abc
def
abef

Sample Output

60
Source: ACM ICPC NEERC, 2011
loading