#P9414. 「NnOI R1-T3」元组
「NnOI R1-T3」元组
Background
Little L really likes trees, really likes , and really likes ordered tuples, so this problem was created.
Problem Description
For a rooted tree with nodes (the root is ), define a strictly increasing ordered -tuple to be a level- -tuple if and only if:
- .
- There exists a node such that for any strictly increasing ordered -tuple , we have .
Note that means the lowest common ancestor of nodes and in the tree, and means the of all .
Find the number of level- -tuples, modulo .
Input Format
The first line contains three integers .
The next lines each contain two integers, representing the endpoints of an edge.
Output Format
Output one integer, the required answer.
6 4 3
1 2
2 3
3 4
3 5
3 6
1
6 3 2
1 2
1 3
1 4
1 5
1 6
20
6 4 2
1 2
1 3
2 4
2 5
3 6
0
Hint
Sample 1 Explanation
For sample , we find that the only valid -tuple is .
Constraints
For of the testdata, , and .
Note: This problem uses bundled testcases.
- Subtask 1 (10 pts): .
- Subtask 2 (20 pts): .
- Subtask 3 (30 pts): .
- Subtask 4 (10 pts): Node has a direct edge to every node.
- Subtask 5 (30 pts): No special restrictions.
Contributors
data&check: EstasTonne. (The problem setter of the next problem number under this problem in the problemset.)
Translated by ChatGPT 5