F002A. Infixes

Your task is to write a program that reads a sequence of words and
prints, for each word, all the other words of the sequence contained in
it.

Your program has to implement and use the function

        bool contains(string s1, string s2);

that returns if the word |s1| contains the word |s2| under the
precondition that the length of |s1| is greater or equal than the length
of |s2|.

For instance, |contains ("enlightenment", "light")|, |contains
("enlightenment", "enlightenment")|, |contains ("enlightenment",
"lighten")| and
|contains ("enlightenment", "ten")| have to return |true|, but, however,
|contains ("enlightenment", "ei")|
and |contains ("enlightenment", "might")| have to return |false|.

Input

Input consists in a natural number n followed by n different words
p₁, …, p_(n).

Output

The program has to print a line for each p₁, …, p_(n) in this order.
Each line starts with p_(i), followed by the symbol “:” and the list of
all the input words contained in p_(i), in the same order than the
input. Notice that the list corresponding to each p_(i) always includes
p_(i), since every word contains itself.

Problem information

Author: Unknown
Translator: Carlos Molina

Generation: 2026-01-25T10:38:50.136Z

© Jutge.org, 2006–2026.
https://jutge.org
