#P6132. [集训队互测 2019] 简单计数
[集训队互测 2019] 简单计数
Description
Legend says that a long, long time ago, there was a labeled directed acyclic graph (DAG) with vertices. Each edge has a color, which is one of different colors. The graph satisfies the following properties:
- Each vertex has at most outgoing edge.
- The in-degree of each vertex belongs to the set .
For some reason, you want to know how many such graphs there are. Since the number may be huge, output the answer modulo .
Two graphs are different if and only if there exists a directed edge from some vertex to some vertex that appears in exactly one of the two graphs, or appears in both graphs but with different colors.
Input Format
The first line contains three positive integers .
The second line contains distinct non-negative integers in increasing order, representing the elements of the set .
Output Format
Output one integer in , the number of graphs satisfying the conditions modulo .
3 1 2
0 1
13
8 2 3
0 2 3
7497953
3000 2 3
0 1 3
500207304
10000000 3 2
0 3
238588124
876543210 233 4
0 1 2 3
467638557
Hint
[Explanation for Sample 1]
There are graphs satisfying the conditions. Here denotes a directed edge from to :
- No edges.
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
[Constraints]
The testdata is divided into subtasks.
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): no special constraints.
For of the testdata, , , , and .
By: fjzzq2002
Source: CTT Mutual Test 2019 Day 5.
Input Format
The first line contains three positive integers .
The second line contains distinct non-negative integers in increasing order, representing the elements of the set .
Output Format
Output one integer in , the number of graphs satisfying the conditions modulo .
Hint
[Explanation for Sample 1]
There are graphs satisfying the conditions. Here denotes a directed edge from to :
- No edges.
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
- .
[Constraints]
The testdata is divided into subtasks.
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): .
- Subtask ( points): no special constraints.
For of the testdata, , , , and .
By: fjzzq2002
Source: CTT Mutual Test 2019 Day 5.
Translated by ChatGPT 5
京公网安备 11011102002149号