Editorial for COCI '15 Contest 2 #2 Geppetto
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
In this task, we need to count how many combinations, out of the possible, meet the requirements for combining the ingredients.
To begin with, for each ingredient , we can create an array of ingredients that cannot be combined with that ingredient.
After this, we solve the task by recursively looping through the ingredients and trying to do the following:
- Choose the ingredient - only if we haven't already chosen an ingredient that cannot be combined with the current one.
- Do not choose the ingredient.
Comments