#P10064. [SNOI2024] 公交线路
[SNOI2024] 公交线路
Problem Description
Given an unrooted tree with nodes. We want to build bus routes between some pairs of nodes so that between any two nodes, it takes at most two bus routes to travel.
Formally, consider all simple paths on the tree whose endpoints are different. For a subset of these paths, we call it good if and only if:
- Consider a new graph . For a pair of nodes , if and only if there exists a path in such that both and lie on , we add an undirected edge of weight between and .
- Require that the distance between any two nodes in is at most .
You need to compute how many subsets are good. Since the answer may be large, output it modulo .
Input Format
The first line contains a positive integer , the number of nodes.
The next lines each contain two positive integers , representing a tree edge .
Output Format
Output one integer, the answer modulo .
3
1 2
2 3
5
6
1 2
2 3
2 4
3 5
3 6
27296
Hint
[Sample #1 Explanation]
For the first sample, all feasible plans are $\{(1, 3)\}, \{(1, 3), (1, 2)\}, \{(1, 3), (2, 3)\}, \{(1, 3), (1, 2), (2, 3)\}, \{(1, 2), (2, 3)\}$.
[Sample #3]
See the attachments bus/bus3.in and bus/bus3.ans.
This sample satisfies the constraints of testdata .
[Sample #4]
See the attachments bus/bus4.in and bus/bus4.ans.
This sample satisfies the constraints of testdata .
[Constraints]
For all testdata, it is guaranteed that .
Details are as follows:
| Testdata ID | Special Property | |
|---|---|---|
| None | ||
| A | ||
| None | ||
Special property A: the tree is a chain.
Translated by ChatGPT 5