#P9960. Guess the Animal
Guess the Animal
Guess the Animal
Bessie and her friend Elsie are tired of their usual nut‐shell game and decide to try another popular game called "Guess the Animal." In this game, Bessie secretly chooses an animal (most of the time it is a cow, which makes the game rather boring; however, Bessie occasionally opts for a different animal to spice things up). Elsie then asks a series of yes/no questions about the animal's features in order to deduce which animal Bessie has chosen. For example:
Elsie: "Does this animal fly?" Bessie: "No." Elsie: "Does it eat grass?" Bessie: "Yes." Elsie: "Does it produce milk?" Bessie: "Yes." Elsie: "Does it moo?" Bessie: "Yes." Elsie: "Then I guess it is a cow." Bessie: "Correct!"
At any point during the game, the feasible set consists of all animals that exhibit every feature that Elsie has asked about so far. Elsie continues questioning until the feasible set is reduced to a single animal, at which point she makes her guess. Note that Elsie might ask about a feature even if it does not help reduce the feasible set further, and she will never ask about the same feature twice.
You are given all the animals known to Bessie and Elsie along with their respective features. Compute the maximum number of "yes" answers Elsie could receive before correctly guessing the animal. Formally, if for any two distinct animals the number of common features is \(c\), then the answer is \(c+1\) (i.e., the maximum over all pairs of animals).
Note: All formulas are provided in \(\LaTeX\) format.
inputFormat
The first line of input contains a single integer \(n\) (\(1 \le n \le 100\)) representing the number of animals. The following \(n\) lines each describe an animal. Each line starts with the animal's name (a string without spaces) followed by an integer \(k\) (\(1 \le k \le 100\)) indicating the number of features the animal has. This is followed by \(k\) strings identifying the features.
outputFormat
Output a single integer representing the maximum number of "yes" answers Elsie could receive before she is forced to make the correct guess.
sample
3
cow 4 flies eatsgrass producesmilk moos
sheep 3 eatsgrass moos wool
goat 3 producesmilk eatsgrass climbs
3