#K15646. Unique Recipe Tag Length
Unique Recipe Tag Length
Unique Recipe Tag Length
You are given a list of recipes. Each recipe consists of a list of ingredients. The recipes are processed in the given order. For each recipe, you need to compute the number of ingredients that are unique to that recipe at the time of its processing. An ingredient is considered unique for a recipe if it did not appear in any of the recipes processed before.
More formally, let \(R_i\) denote the set of ingredients in the \(i\)-th recipe, and let \(C\) denote the set of all ingredients that have appeared in recipes \(1, 2, \ldots, i-1\). Then the unique tag length for recipe \(i\) is given by \(|R_i \setminus C|\). After processing recipe \(i\), update \(C\) to include all ingredients from \(R_i\).
Your task is to output the unique tag lengths for all recipes in order, separated by spaces.
Input/Output Format: The input is read from standard input and the output is written to standard output.
inputFormat
The first line of input contains an integer \(n\) representing the number of recipes. This is followed by \(n\) groups of lines, one for each recipe. For each recipe, the first line contains an integer \(m\) representing the number of ingredients in that recipe, followed by \(m\) lines each containing one ingredient (a string).
outputFormat
Output a single line containing \(n\) integers separated by a single space. Each integer represents the unique tag length for the corresponding recipe in the order they are processed.
## sample3
4
sugar
milk
egg
flour
3
butter
sugar
vanilla
2
potato
cheese
4 2 2