#P1666. 前缀单词

前缀单词

Description

A set of words is safe if and only if no word is a prefix of another word; this ensures that the data is not easily misunderstood. Now you have a word set SS, and you need to count how many of its subsets are safe.

Note that the empty set is always safe.

Input Format

The first line contains an integer nn, the size of the set. Then nn lines follow. Each line contains a string consisting of \verb!a!\cdots\verb!z!.

Output Format

The number of safe subsets.

3
hello
hell
hi
6

Hint

Constraints and Conventions

  • For 30%30\% of the testdata, it holds that 1n101 \le n \le 10.
  • For 100%100\% of the testdata, it holds that 1n501 \le n \le 50, string length 50\le 50, and no two strings are exactly the same.

Translated by ChatGPT 5