#P14666. [KenOI 2025] 游走题
[KenOI 2025] 游走题
Description
Given a rooted tree with nodes, rooted at node . Now let's start the wander from node , abiding by the following rules:
- If we have gone to 's parent from , delete the edge immediately.
- When has no neighbor, the wander stops.
For two plans , we call they are essentially different only when the sets of nodes they pass through are different. It can be proven that if plan are the same, the numbers of step that their token are also the same.
Compute the sum of the lengths of all essentially different walks, modulo .
Input Format
The first line contains two integers and .
The next lines each contains two positive integers and , representing an edge .
Output Format
A single integer, the sum of the lengths modulo .
7 5
2 1
3 2
4 2
5 3
6 5
7 3
48
Hint
Example explanation
Consider all possible essentially different paths:
-
;
-
;
-
;
-
;
-
;
-
;
-
;
-
;
The sum is .
Data Volume and Conventions
This problem is divided into subtasks. Your score in a subtask is the minimum score across all its test cases.
This problem uses subtask dependencies. You will not receive the score for a subtask unless you achieve full points on all its dependent subtasks.
| Subtask | Special Properties | Score | Dependencies | |
|---|---|---|---|---|
| none | none | |||
| A | none | |||
| B | ||||
| C | ||||
| none |
Special property A: .
Special property B: .
Special property C: .
For all of the cases, .
京公网安备 11011102002149号