問題一覧 > 通常問題

No.758 VVVVV

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 36
作問者 : polylogK / テスター : matsu7874
お気に入りにしたユーザー ProblemId : 2578 / 自分の提出
問題文最終更新日: 2018-12-02 15:41:53
VVVVV
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
Advent Calendar Contest 2018 (順位表) の他の問題:

Problem Statement

You are given an ordered tree with N vertices rooted at vertex 1.
When performing a DFS on this ordered tree from the root, there are two kinds of moves: "descending from a parent to a child" and "returning from a child to its parent". We call them move A and move B, respectively.
Also, let M be the number of times the move "changes from move A to move B, or from move B to move A" during the DFS of this ordered tree.
Find the number, modulo MOD $10^9 + 7$, of ordered trees with N vertices for which the number of times the move "changes from move A to move B, or from move B to move A" during the DFS is equal to M.

Input

$N$
$a_1\ b_1$
$a_i\ b_i$
$a_{N - 1}\ b_{N - 1}$

The first line gives the number of vertices $N (1 \le N \le 10^5)$.
The following N - 1 lines give the edges; each edge connects vertex $a_i$ and vertex $b_i$ with each other.
$1 \le a_i, b_i \le N$

Output

Output the number of ordered trees modulo MOD $10^9 + 7$.

Sample

Sample 1
Input
5
1 2 
2 3
2 4
3 5
Output
6

Writing the DFS moves using A and B,
we get AAABBABB, and the number of times the kind of move changes is 3.

Sample 2
Input
10
1 2
1 3
3 4
3 5
4 6
2 7
5 8
4 9
7 10
Output
1176

Sample 3
Input
30
1 2
2 3
2 4
4 5
3 6
1 7
3 8
3 9
3 10
10 11
8 12
8 13
10 14
10 15
12 16
3 17
5 18
1 19
16 20
13 21
21 22
7 23
7 24
17 25
25 26
21 27
14 28
18 29
23 30
Output
493001124

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。