atcoder#ARC114B. [ARC114B] Special Subsets
[ARC114B] Special Subsets
Score : points
Problem Statement
Let be a set composed of all integers from through .
is a function from to . You are given the values as .
Find the number, modulo , of non-empty subsets of satisfying both of the following conditions:
- For every , .
- For every , if .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of non-empty subsets of satisfying both of the conditions, modulo .
2
2 1
1
We have . Since , the second condition is always satisfied, but the first condition requires to contain and simultaneously.
2
1 1
1
We have . The first condition requires to contain , and the second condition forbids to contain .
3
1 2 3
7
We have . Both of the conditions are always satisfied, so all non-empty subsets of count.