Good Set
Time limit1sMemory limit1024 MB
Count the nonempty subsets of {0, ..., 2^k - 1} that are closed under bitwise AND and OR and contain all given n integers, with k up to 7.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Dynamic programming, Combinatorics
- Solved
- No attempts yet
Problem
Seunghyun is a mathematician, and he likes good jokes.
For a set , a nonempty subset is good if it satisfies the following rules.
- For any , their bitwise AND is in .
- For any , their bitwise OR is in .
You are given distinct integers in the range . Find the number of good sets that contain all integers.
Input
The first line contains two integers and (, ).
The next line contains distinct integers ().
Output
Print a single integer, the number of good sets.