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.

In this task, we need to count how many combinations, out of the 2^N possible, meet the requirements for combining the ingredients.

To begin with, for each ingredient i, we can create an array of ingredients j 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:

  1. Choose the ingredient - only if we haven't already chosen an ingredient that cannot be combined with the current one.
  2. Do not choose the ingredient.

Comments

There are no comments at the moment.