#P16554. [ICPC 2026 LAC] Holes and Tunnels
[ICPC 2026 LAC] Holes and Tunnels
题目描述
Path-Digging Animals (PDA) is a new cooperative game for two players that is gaining popularity among programmers. The game is played on a board having holes and bidirectional tunnels. The tunnels form an undirected tree, which means that there is a unique simple path between each pair of holes.
A route in PDA is a simple path between two different holes. Since tunnels are bidirectional, the direction of a route is not relevant: the (unique) route from hole to hole and the (unique) route from hole to hole are the same route.
Players use animal-shaped pieces for playing PDA. In each round of the game, each player independently chooses a route which is traversed by their animal, and both players score as many points as the number of tunnels that their routes have in common.
Right now Alicia and Bruno are at a board game party in Chile playing PDA, and they want to analyze their scoring possibilities. They would like to know, for each integer from to , how many ordered pairs of routes there are such that Alicia and Bruno score exactly points if Alicia chooses route and Bruno chooses route .
输入格式
The first line contains an integer () indicating the number of holes. Each hole is identified by a distinct integer from to .
Each of the next lines contains two integers and ( and ), representing that there is a bidirectional tunnel between holes and . It is guaranteed that the tunnels form an undirected tree.
输出格式
Output a single line with integers , where indicates the number of ordered pairs of routes such that Alicia and Bruno score exactly points if Alicia chooses route and Bruno chooses route . Because these numbers can be very large, output the remainder of dividing each of them by .
3
1 3
2 3
6 1
提示
Explanation of Sample 1:
There are three possibilities for Alicia's route : the route between holes and (formed by the single tunnel between these holes), the route between holes and (again a single tunnel), and the route between holes and (containing both tunnels). The same three possibilities are available for Bruno's route . The table below shows the score for each combination. As can be seen, ordered pairs of routes yield a score of point, while pair gives points. Applying the modulo operation does not change these results.
:::align{center}
:::