Animal Enclosures

There are a number of animals who are grouped in enclosures. Write a
program that keeps track of which enclosure each animal belongs to. Each
animal has a name and a species among the four types “elephant”, “frog”,
“cat”, or “undefined”.

Input

The input starts with an integer N denoting the number of animals. The
next N lines are on the format “<animal type> <animal name>”, where
<animal type> is the type of the animal (Elephant, Frog, Cat or Animal)
and <animal name> is the name of the animal.
The next line has an integer M denoting the number of enclosures. The
enclosures are given on the following lines on the format “<enclosure
name>  < K>, where K is the number of animals in the enclosure. Each
enclosure is followed by K lines with the names of the animals.

Output

For each animal in the order they appear in the input, print the
following line:
X is of the species Y
For each enclosure in the order they appear in the input, print the
following line:
Enclosure Z contains animals AA, BB, CC, ...
All placeholders (X, Y, Z, AA, BB, CC) should be replaced with the
appropriate name or species (see the sample output for an example).

Problem information

Author: Anders Jonsson

Generation: 2026-01-25T14:19:14.831Z

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