Geppetto's Pizza
InterviewTime limit1sMemory limit64 MB
Count the subsets of up to 20 ingredients that contain none of the given incompatible pairs, including the empty pizza.
- Level
Medium4 of 10
- Topics
- Brute force, Bit manipulation
- Solved
- No attempts yet
Problem
Geppetto has opened the best pizza place in town. The ingredients he can put on a pizza are numbered through , and he builds each pizza by choosing any set of them.
The trouble is that some ingredients do not mix. There are pairs of ingredients that cannot sit on the same pizza. Neither pair may appear together on one pizza.
Count how many different pizzas Geppetto can make. Two pizzas are different if some ingredient is on one of them and not on the other. A pizza with no ingredients at all counts as one pizza.
Input
The first line contains two integers and separated by a space. (, )
Each of the next lines contains two different integers and . () Ingredient and ingredient cannot be on the same pizza. The same pair may be given more than once.
Output
Print the number of different pizzas Geppetto can make.