AtCoder Regular Contest 130
D
Zigzag Tree
AtCoder
⌀ 2437
原题
← CE →
翻译中…

Problem Statement

翻译中…

Given is a tree with $N$ vertices. The vertices are numbered $1$ to $N$, and the $i$-th edge connects Vertices $a_i$ and $b_i$.

翻译中…

Find the number of sequences of positive integers $P = (P_1, P_2, \ldots, P_N)$ that satisfy the conditions below, modulo $998244353$.

翻译中…
  • $1\leq P_i\leq N$
  • $P_i\neq P_j$ if $i\neq j$.
  • For $1\leq a, b, c\leq N$, if Vertices $a$ and $b$ are adjacent, and Vertices $b$ and $c$ are also adjacent, $P_a < P_b > P_c$ or $P_a > P_b < P_c$ holds.
翻译中…

Constraints

翻译中…
  • $2\leq N\leq 3000$
  • $1\leq a_i, b_i\leq N$
  • The given graph is a tree.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
a_1 b_1
a_2 b_2
\vdots
a_{N-1} b_{N-1}

翻译中…

Output

翻译中…

Print the answers.

翻译中…

样例

Input #1
3
1 2
2 3
Output #1
4
The $4$ sequences satisfying the conditions are: - $P = (1, 3, 2)$ - $P = (2, 1, 3)$ - $P = (2, 3, 1)$ - $P = (3, 1, 2)$
Input #2
4
1 2
1 3
1 4
Output #2
12
Input #3
6
1 2
2 3
3 4
4 5
5 6
Output #3
122
Input #4
9
8 5
9 8
1 9
2 5
6 1
7 6
3 8
4 1
Output #4
19080
题目信息
题号
arc130_d
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。