| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 3 초 (추가 시간 없음) | 1024 MB (추가 메모리 없음) | 210 | 81 | 61 | 40.667% |
BOOM! Dohoon’s head has exploded while solving the tree decomposition practice problem given as an assignment while attending the Summer School on Combinatorics and Algorithms at KAIST. Dohoon’s brain, now unable to focus on the problem, is idling away time performing ‘decomposition’ on a ‘tree’ instead of doing tree decomposition on general graphs.
Specifically, Dohoon is given a tree with $N$ vertices. He plans to decompose the tree into a collection of connected components as follows:
Help Dohoon find the number of different ways to decompose the tree as given above. To be specific, determine the number of possible sets of edges $S$ that satisfy the given conditions.
Note that a tree is a connected, acyclic, undirected graph, where each undirected edge is an unordered pair of vertices.
The first line contains three space-separated integers, $N,ドル $A,ドル $B$.
The $i$-th of the following $N-1$ lines contains two space-separated integers $x_i$ and $y_i,ドル denoting that the $i$-th edge connects vertices $x_i$ and $y_i$ in the tree.
Print the number of possible sets $S$ that satisfy the conditions given in the problem, modulo 10ドル^9+7$.
6 1 2 1 2 2 3 2 4 4 5 4 6
10