eolymp
bolt
Try our new interface for solving problems
Məsələlər

File Retrieval

File Retrieval

The operating system of your computer indexes the files on your hard disk based on their contents, and provides textual search over them. The content of each file is a non-empty string of lowercase letters. To do a search, you specify a key, which is also a non-empty string of lowercase letters. The result is a list of all the files that contain the key as a substring. A string \textbf{s} is a substring of a string \textbf{t} if \textbf{t} contains all characters of \textbf{s} as a contiguous sequence. For instance, "\textbf{foofoo}", "\textbf{cafoo}", "\textbf{foota}" and "\textbf{foo}" all contain "\textbf{foo}" as a substring, while "\textbf{foa}", "\textbf{fofo}", "\textbf{ oo}" and "\textbf{oofo}" do not. You know the content of each file on your hard disk, and wonder whether each subset of the les is searchable. A subset of the files is searchable if there exists at least one key that produces exactly the list of those files as a result. Given the contents of the files on your hard disk, you are asked to compute the number of non-empty searchable subsets. \InputFile Each test case is described using several lines. The first line contains an integer \textbf{F} representing the number of files on your hard disk (\textbf{1} ≤ \textbf{F} ≤ \textbf{60}). Each of the next \textbf{F} lines indicates the content of one of the files. The content of a file is a non-empty string of at most \textbf{10^4} characters; each character is one of the \textbf{26} standard lowercase letters (from '\textbf{a}' to '\textbf{z}'). The last test case is followed by a line containing one zero. \OutputFile For each test case output a line with an integer representing the number of non-empty searchable subsets.
Zaman məhdudiyyəti 10 saniyə
Yaddaşı istafadə məhdudiyyəti 128 MiB
Giriş verilənləri #1
6
form
formal
malformed
for
man
remake
3
cool
cool
old
0
Çıxış verilənləri #1
11
3
Mənbə ACM ICPC Latin America 2011, November 4th-5th, 2011